June 2018
Beginner to intermediate
394 pages
9h 2m
English
Firestore supports offline data persistence, and when a network reconnects, it will push or synchronize local changes with the cloud changes. To enable offline support, use the following code snippet:
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder() .setPersistenceEnabled(true) .build();db.setFirestoreSettings(settings);
The preceding code will enable your application to function offline. Once you have enabled the offline persistence, your listeners will receive the events whenever the local cache data changes. Consider the following code example that listens to the offline event changes:
db.collection("cities").whereEqualTo("state", "CA") .addSnapshotListener(new EventListener<QuerySnapshot ...
Read now
Unlock full access