脚本
我在Play商店发布了我的应用程序
-
Firebase实时数据库
-
为我的每个Firebase数据库设置了setPersistenceEnabled(true) .
在跟踪崩溃几周后,我遇到了this崩溃 .
经过一些研究,我得出结论, inconsistency in data cached by Firebase Database's data persistence 可能是这次崩溃的原因 .
因此,我通过为所有数据库调用 FirebaseDatabase.getInstance().setPersistenceEnabled(false);
来关闭数据持久性 .
随着代码的上述变化,我在Play商店发布了我的应用更新 .
但是用户(在禁用持久性的新版本上)仍然会崩溃 .
所以我的疑问是
1) Will the app use persisted data even after turning off persistence?
2) Do the user need to clear the app data which will eliminate the crash? (as inconsistent/corrupted cached data is the reason behind the crash)
下面是我的应用程序中与firebase数据库相关的gradle依赖项
compile 'com.google.firebase:firebase-database:12.0.1'
compile 'com.firebaseui:firebase-ui-database:3.3.0'
1 回答
答案是不 . 使用以下代码行后:
这意味着您在离线时将无法查询数据库 . 此功能将被禁用 . 更清楚的是,使用Firebase数据库并使用setPersistenceEnabled(false)的每个客户端都将 not 维护它自己的数据库内部(本地)版本 .
但是,通过启用持久性,Firebase实时数据库客户端在联机时可以同步的任何数据都会保留到磁盘并且可以脱机使用,即使用户或操作系统重新启动应用程序也是如此 . 这意味着您的应用程序将使用存储在缓存中的本地数据在线工作 .