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
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)
Enables the use of Timestamps for timestamp fields in DocumentSnapshots.

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 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)

Enables the use of Timestamps for timestamp fields in DocumentSnapshots.

Currently, Firestore returns 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.

Setting setTimestampsInSnapshotsEnabled(true) will cause Firestore to return Timestamp values instead of Date, avoiding this kind of problem. To make this work you must also change any code that uses Date to use Timestamp instead.

NOTE: in the future areTimestampsInSnapshotsEnabled() will default to true and this option will be removed so you should change your code to use Timestamp now and opt-in to this new behavior as soon as you can.

Returns
  • A settings object on which the return type for timestamp fields is configured as specified by the given value.

Send feedback about...

Need help? Visit our support page.