在Android是有什么办法preserve共享preferences卸载后,有什么办法、Android、preferences、preserve

由网友(滿身驕傲)分享简介:我保持了一些应用程序元数据共享preferences 。每当我卸载应用程序,并重新安装,在共享preferences 被删除。I am keeping some application meta data in SharedPreferences. Whenever I uninstall the applicati...

我保持了一些应用程序元数据共享preferences 。每当我卸载应用程序,并重新安装,在共享preferences 被删除。

I am keeping some application meta data in SharedPreferences. Whenever I uninstall the application and reinstall it, the SharedPreferences are deleted.

有没有办法让留,这样,如果用户卸载并重新安装,就可以恢复他们的旧数据?

Is there any way to get that to remain, so that if the user does an uninstall and reinstall, they can recover their old data?

推荐答案

您应该添加 BackupAgentHelper 您的应用程序。连同共享preferenceBackupHelper ,它备份的共享preferences 云(如果设备支持的话)。当应用程序被重新安装数据恢复。

You should add a BackupAgentHelper to your app. Together with the SharedPreferenceBackupHelper, it backups the SharedPreferences to the cloud (if the device supports it). When the app is reinstalled the data is restored.

请参阅:

BackupAgentHelper

Shared$p$pferenceHelper (包含了所有你需要实现它的code)

常规备份指南

阅读全文

相关推荐

最新文章