Are the shared preferences associated with the App deleted when the app is removed?

萝らか妹 提交于 2019-12-23 15:11:16

问题


Are SharedPreferences value for an App retained even after it is removed?

If not, I would like to retain the SharedPreferences even after the app is uninstalled/removed. Is there a way?

Edit: I am reluctant to store the settings on the SD Card. Is there a way I can store them in the phone memory itself?


回答1:


SharedPreferences are deleted when an app is uninstalled, but you can use the BackupManager to perform a backup into the cloud - Reto Meier has a good blog post for getting you started.

This approach means if a user installs you app onto a new phone they can have their preferences copied over to there as well.




回答2:


Yes shared preferences are stored in the data directory for the application. When the app is uninstalled the file is removed.

If you want to retain a shared preferences you'll need to work with a file on the sd card.




回答3:


Yes they will get deleted. You would have to store a backup on SD card and restore it upon re-installation.



来源:https://stackoverflow.com/questions/6907916/are-the-shared-preferences-associated-with-the-app-deleted-when-the-app-is-remov

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!