我正在開發一個應用程序,我將每個表單數據保存到SharedPreferences。它工作正常,但是當我毀了我的程序,我回應用程序中的表單數據仍然exists.Cause我的應用程序需要在運行Android權限設置和SharedPreferences問題
允許我嘗試:
- 填寫我的第一形式
- 轉到我的第二個表格並填寫
- 回到第一形式(因運行時允許存在於這裏,當一個按鈕點擊)
- 打開設置
- 禁用Pe的rmission
- 打開我的應用程序
- 我的第二個表格的數據丟失
我嘗試另一種情況下,像摧毀應用程序。打開另一個應用,我的表單仍然存在。只需在設置 - >應用程序 - >權限和禁用權限。
是Android做一些檢查或任何活動,使我的 偏好損失?
我創造我的首選項UTIL這樣的:
/**
* Initialize the Prefs helper class to keep a reference to the SharedPreference for this
* application the SharedPreference will use the package provinceName of the application as the Key.
*
* @param context the Application context.
*/
public static void initPrefs(Context context) {
if (mPrefs == null) {
String key = context.getPackageName();
if (key == null) {
throw new NullPointerException("Prefs key may not be null");
}
mPrefs = context.getSharedPreferences(key, Context.MODE_PRIVATE);
}
}
謝謝
請提供一些碼。你在哪裏存儲和加載值的形式(S)? – deHaar