我正在使用一个将数据添加到Firestore服务器的Android应用程序,但是遇到了问题。当我的设备离线时,从逻辑上讲不会将其添加到Firestore中,但是当设备再次恢复在线时,所有数据都会以某种方式缓存并添加到Firestore中。
这给我带来了数据不一致的问题,那么有没有办法禁用此行为?
答案 0 :(得分:1)
您所描述的是预期的行为。
如果您不希望发生这种情况,则应该disable persistence as described in the documentation。请注意,您还将禁用读取缓存。没有禁用读缓存就无法禁用写缓存。
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(true)
.build();
db.setFirestoreSettings(settings);