FirebaseFirestoreSettings.Builder

public static final class FirebaseFirestoreSettings.Builder extends Object

A Builder for creating FirebaseFirestoreSettings.

Public Constructor Summary

FirebaseFirestoreSettings.Builder()
Constructs a new FirebaseFirestoreSettings Builder object.
FirebaseFirestoreSettings.Builder(FirebaseFirestoreSettings settings)
Constructs a new FirebaseFirestoreSettings Builder based on an existing FirebaseFirestoreSettings object.

Public Method Summary

FirebaseFirestoreSettings
FirebaseFirestoreSettings.Builder
setCacheSizeBytes(long value)
Sets an approximate cache size threshold for the on-disk data.
FirebaseFirestoreSettings.Builder
setHost(String host)
Sets the host of the Firestore backend.
FirebaseFirestoreSettings.Builder
setPersistenceEnabled(boolean value)
Enables or disables local persistent storage.
FirebaseFirestoreSettings.Builder
setSslEnabled(boolean value)
Enables or disables SSL for communication.
FirebaseFirestoreSettings.Builder
setTimestampsInSnapshotsEnabled(boolean value)
This method was deprecated. This setting now defaults to true and will be removed in a future release. If you are already setting it to true, just remove the setting. If you are setting it to false, you should update your code to expect Timestamps instead of Dates and then remove the setting.

Inherited Method Summary

Public Constructors

public FirebaseFirestoreSettings.Builder ()

Constructs a new FirebaseFirestoreSettings Builder object.

public FirebaseFirestoreSettings.Builder (FirebaseFirestoreSettings settings)

Constructs a new FirebaseFirestoreSettings Builder based on an existing FirebaseFirestoreSettings object.

Public Methods

public FirebaseFirestoreSettings build ()

public FirebaseFirestoreSettings.Builder setCacheSizeBytes (long value)

Sets an approximate cache size threshold for the on-disk data. If the cache grows beyond this size, Firestore will start removing data that hasn't been recently used. The size is not a guarantee that the cache will stay below that size, only that if the cache exceeds the given size, cleanup will be attempted.

By default, collection is disabled (the value is set to CACHE_SIZE_UNLIMITED). In a future release, collection will be enabled by default, with a default cache size of 100 MB. The minimum value is 1 MB.

Returns
  • A settings object on which the cache size is configured as specified by the given value.

public FirebaseFirestoreSettings.Builder setHost (String host)

Sets the host of the Firestore backend.

Parameters
host The host string
Returns
  • A settings object with the host set.

public FirebaseFirestoreSettings.Builder setPersistenceEnabled (boolean value)

Enables or disables local persistent storage. The default is to use local persistent storage.

Returns
  • A settings object that uses local persistent storage as specified by the given value.

public FirebaseFirestoreSettings.Builder setSslEnabled (boolean value)

Enables or disables SSL for communication. The default is to use SSL.

Returns
  • A settings object that uses SSL as specified by the value.

public FirebaseFirestoreSettings.Builder setTimestampsInSnapshotsEnabled (boolean value)

This method was deprecated.
This setting now defaults to true and will be removed in a future release. If you are already setting it to true, just remove the setting. If you are setting it to false, you should update your code to expect Timestamps instead of Dates and then remove the setting.

Specifies whether to use Timestamps for timestamp fields in DocumentSnapshots. This is now enabled by default and should not be disabled.

Previously, Firestore returned timestamp fields as Date but Date only supports millisecond precision, which leads to truncation and causes unexpected behavior when using a timestamp from a snapshot as a part of a subsequent query.

So now Firestore returns Timestamp values instead of Date, avoiding this kind of problem.

To opt into the old behavior of returning Dates, you can temporarily set areTimestampsInSnapshotsEnabled() to false.