How To Force To Get Cached Documents In Firestore ? I Want To Get Cached Documents When Online
so I have this method to query documents from Firestore: FirestoreCollectionReference.event.getReference() .whereEqualTo(FIRESTORE_EVENT_FIELD_CITY,selectedCity)
Solution 1:
If you want to explicitly control where get()
gets its data from, you can pass in a Source
parameter that tells it what to do:
.get(Source.CACHE)
or
.get(Source.SERVER)
Also see the guide and reference documentation for get(Source)
.
Solution 2:
Use this for Firestore Settings (this is in Kotlin)
val firestoreSettings: FirebaseFirestoreSettings = FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(false/*OR True | Control it whenever you need*/)
.setSslEnabled(true)
.build()
firebaseFirestore.firestoreSettings = firestoreSettings
Post a Comment for "How To Force To Get Cached Documents In Firestore ? I Want To Get Cached Documents When Online"