我的应用程序将所有用户数据和首选项存储在SQLite数据库中,如果用户获得新手机,重新安装或恢复出厂设置,我希望将其保留。我已经在Android's Data Backup Guide及其Android Backup Service中完成了一些阅读,但在开始之前仍然有一些问题。
dataChanged()
然后在BackupManager调用{{}}之前再次发生相同问题1}},如何处理这些数据更改? BackupManager是否只备份最新版本的数据库(应该包括两个更改)? onBackup()
简单地备份数据库,因为it looks pretty simple to do。至少有一位开发人员似乎有resolved at least some compatibility issues by disabling Write Ahead Logging。如果我采用这种方法,我可以期待什么样的失败率?如果非常高,我可能会考虑转换为CSV文件并在此过程中返回。 要确保备份代理不会在活动的同时读取或写入文件,每次执行读取或写入时都必须使用synchronized语句。
FileBackupHelper
语句中对数据库进行每次读/写操作?即,我必须将这个添加到我的活动从db加载或写入信息的每个地方?那是很多地方。synchronized
?感谢您的帮助。我只是想做到这一点,让我的用户在今年圣诞节获得新手机时感到高兴!
答案 0 :(得分:1)
这应该回答你的1和2问题:
Android automatically performs a restore operation when your application is installed and there
exists backup data associated with the user. The primary scenario in which backup data is restored
is when a user resets their device or upgrades to a new device and their previously installed
applications are re-installed.
3: 由于您的数据将在安装过程中恢复,因此我认为您不会遇到并发问题
4:
Data backup is not guaranteed to be available on all Android-powered devices. However, your
application is not adversely affected in the event that a device does not provide a backup
transport. If you believe that users will benefit from data backup in your application, then you can
implement it as described in this document, test it, then publish your application without any
concern about which devices actually perform backup.
5: 我不这么认为。
6: "每次执行读或写时#34;似乎是不言自明的。 每次在DB上执行操作