Jeśli słuchasz danych w chmurze FireStore, otrzymasz natychmiastowe migawek pamięci podręcznej danych, a także aktualizuje, gdy aplikacja jest w stanie połączyć się z siecią:
final DocumentReference docRef = db.collection("cities").document("SF");
docRef.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot snapshot,
@Nullable FirebaseFirestoreException e) {
if (e != null) {
Log.w(TAG, "Listen failed.", e);
return;
}
// Determine if the data came from the server or from cache
String source = snapshot != null && snapshot.getMetadata().hasPendingWrites()
? "Local" : "Server";
// Read the data
if (snapshot != null && snapshot.exists()) {
Log.d(TAG, source + " data: " + snapshot.getData());
} else {
Log.d(TAG, source + " data: null");
}
}
});
Trwałość jest domyślnie włączona, więc takie zachowanie nie wymaga żadnej konfiguracji.
Wydaje się, że jeśli chcesz zapisać ogromne dane w pamięci podręcznej trybu offline, musisz zsynchronizować dane z 'SQLite' lub innym lokalnym systemem db lub cache. – wonsuc
Witam, czy możesz powiedzieć, jak wstawiasz dane offline w sklepie firewall? –