setPersistenceEnabled method

void setPersistenceEnabled(
  1. bool enabled
)

Attempts to sets the database persistence to enabled.

This property must be set before calling methods on database references and only needs to be called once per application.

The Firebase Database client will cache synchronized data and keep track of all writes you’ve initiated while your application is running. It seamlessly handles intermittent network connections and re-sends write operations when the network connection is restored.

However by default your write operations and cached data are only stored in-memory and will be lost when your app restarts. By setting enabled to true, the data will be persisted to on-device (disk) storage and will thus be available again when the app is restarted (even when there is no network connectivity at that time).

Implementation

void setPersistenceEnabled(bool enabled) {
  return _delegate.setPersistenceEnabled(enabled);
}