在Android是有什么办法preserve共享preferences卸载后, [英] In android is there any way to preserve SharedPreferences after an uninstall

查看:157
本文介绍了在Android是有什么办法preserve共享preferences卸载后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我保持了一些应用程序元数据共享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.

请参阅:

<一个href="http://developer.android.com/reference/android/app/backup/BackupAgentHelper.html">BackupAgentHelper

<一个href="http://developer.android.com/reference/android/app/backup/Shared$p$pferencesBackupHelper.html">Shared$p$pferenceHelper (包含了所有你需要实现它的code)

常规备份指南

这篇关于在Android是有什么办法preserve共享preferences卸载后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆