简体   繁体   English

Android 中的云 Firestore 的离线持久性

[英]Offline persistance with cloud firestore in Android

I am using google cloud firestore to store data.我正在使用 google cloud firestore 来存储数据。 There is an option to enable offline persistance.有一个选项可以启用离线持久性。 My requirement is to have offline support & also that data should be shown after kill & launch of app.我的要求是提供离线支持,并且应该在杀死和启动应用程序后显示数据。
My Queries:我的查询:

  1. Can I use only cloud firestore & have pure offline support.我可以只使用云 Firestore 并拥有纯离线支持吗? [Lets say user entered some data, I push it to cloud firestore & then user kills & launches the app again this time without internet, so can that data be made available directly by cloud firestore or do I need some kind of room implementation] [假设用户输入了一些数据,我将其推送到 Cloud Firestore,然后用户在没有互联网的情况下再次杀死并启动该应用程序,那么这些数据可以直接由 Cloud Firestore 提供,还是我需要某种房间实现]
  2. I have set setPersistenceEnabled as true in firestore settings.我在 firestore 设置中将 setPersistenceEnabled 设置为 true。 Suppose user inserts something, which I try to push it to google firebase.假设用户插入了一些东西,我尝试将其推送到谷歌 firebase。 But that time internet is not available & then user kills the app.但是那个时候互联网不可用,然后用户杀死了该应用程序。 When user again opens the app & internet is available so will that sync be automatically made just by cloud firestore or here again I need to apply some logic & persist data using room & push to firestore manually当用户再次打开应用程序并且互联网可用时,同步将仅由云 Firestore 自动进行,或者再次在这里我需要应用一些逻辑并使用房间持久化数据并手动推送到 Firestore

Link for cloud firestore offline support documentation https://firebase.google.com/docs/firestore/manage-data/enable-offline Cloud Firestore 离线支持文档的链接 https://firebase.google.com/docs/firestore/manage-data/enable-offline

  1. Yes, that's how it works.是的,它就是这样工作的。 Data written while offline is persistent on the device.离线时写入的数据在设备上是持久的。 That's why it's called "offline persistence".这就是为什么它被称为“离线持久性”。

  2. Yes, that's how it works.是的,它就是这样工作的。 It will retry all writes until fully synchronized.它将重试所有写入,直到完全同步。

These are things you should be able to try on your own fairly easily.这些是您应该能够相当容易地自行尝试的事情。

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

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