0

我有一个小的理解问题。我有一个 Android 应用程序,它使用共享首选项来存储数据。为此,我使用:

SharedPreferences settings = getSharedPreferences(prefs, Context.MODE_PRIVATE);

我的问题是,当在新安装了应用程序的其他 android 设备上调用此方法时,是否没有共享首选项文件?

我的另一个问题是,当我在手机上卸载应用程序时,这个文件会发生什么?

4

2 回答 2

2

If you haven't set any preferences it will create a new file. If you uninstall the app it removes the preferences as well. If you update the app they stay.

于 2013-06-13T17:16:45.443 回答
2

SharedPreferences are stored locally on your device and are not synced with your Google account by default. SharedPreferences get deleted when you uninstall the app.

Take a look at my blogpost: http://mikebdev.blogspot.de/2013/05/sharedpreferences-basics.html

于 2013-06-13T17:17:11.223 回答