简体   繁体   English

Firestore中的数据存储用于离线应用程序

[英]Data storage in Firestore For Offline App

I am using Firestore as a NoSQL databse in my Android app. 我在Android应用中将Firestore用作NoSQL数据库。 I want to store data locally in my Android device and avoid syncing with Firestore server in the initial stages of app. 我想将数据本地存储在我的Android设备中,并避免在应用程序的初始阶段与Firestore服务器同步。 Is is possible for the data to persist on device even if app or mobile device restarts without syncing with Firestore database? 即使重新启动应用程序或移动设备而不与Firestore数据库同步,数据也可能保留在设备上吗? If yes then how do I do it ? 如果是,那我该怎么办?

I want to store data locally in my android device and avoid syncing with Firestore server in the initial stages of app. 我想将数据本地存储在我的android设备中,并避免在应用程序的初始阶段与Firestore服务器同步。

According to the official documentation regarding Firestore offline persistens : 根据有关Firestore的官方文档, 离线存在

For Android and iOS, offline persistence is enabled by default. 对于Android和iOS,默认情况下启用离线持久性。 To disable persistence, set the PersistenceEnabled option to false. 要禁用持久性,请将PersistenceEnabled选项设置为false。

And to answer the second question: 并回答第二个问题:

Is is possible for the data to persist on device even if app or mobile device restarts without syncing with Firestore database? 即使重新启动应用程序或移动设备而不与Firestore数据库同步,数据也可能保留在设备上吗?

Yes it is. 是的。 This kind of persistens is called disk persistence , which means that recently listened data (as well as any pending writes from the app to the database) are persisted to disk. 这种持久性称为磁盘持久性 ,这意味着最近侦听的数据(以及从应用程序到数据库的所有挂起的写操作)都将持久化到磁盘。 The data in this cache survives app restarts, and phone reboots. 此缓存中的数据在应用程序重启和手机重启后仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM