在android云中备份数据库:
我可以使用 Android Cloud 备份应用程序的数据库吗?此功能有哪些限制?
Can I use the Android Cloud to back up my application's databases? What are some limits to this feature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。显然它在开发指南中。我想我应该把它放在这里,以便其他人可以从中受益。
BackupAgentHelper 类有
SharedPreferencesBackupHelper 用于备份 SharedPreferences 文件。
FileBackupHelper 从内部存储备份文件。
因此,为了备份数据库,我们需要扩展BackupAgent来备份数据库中的数据。如果您希望在用户重新安装应用程序时恢复 SQLite 数据库,则需要构建一个自定义 BackupAgent,用于在备份操作期间读取适当的数据,然后创建表并在恢复操作期间插入数据。
请访问此链接查看说明:
http://developer.android.com/guide/topics/data/backup .html#BackupAgent
I came across the solution. Apparently it was there in the dev guide.Thought I should put it here so that others can be benefited from it.
The BackupAgentHelper class has
SharedPreferencesBackupHelper to backup SharedPreferences files.
FileBackupHelper to backup files from internal storage.
So in order to back up a database we need to extend BackupAgent to Back up data in a database. If you have an SQLite database that you want to restore when the user re-installs your application, you need to build a custom BackupAgent that reads the appropriate data during a backup operation, then create your table and insert the data during a restore operation.
Please visit this link for illustration:
http://developer.android.com/guide/topics/data/backup.html#BackupAgent