我無法從應用程序點擊事件中刪除SharedPreferences
。共享首選項未被清除,
這裏是我怎樣,我該值存儲到UserInfoActivity SharedPreferences
:
SharedPreferences notificationCountSP = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor notificationEditor = perkBalance.edit();
notificationEditor.putString("notificationCount",notificationCountValue);
notificationEditor.commit();
這裏是如何我試圖從MainActivity清除SharedPreferences
的所有數據:
SharedPreferences clearNotificationSP = getSharedPreferences(
"notificationCountSP", 0);
SharedPreferences.Editor editor = clearNotificationSP.edit();
editor.remove("notificationCount");
editor.clear();
editor.commit();
請告訴我在做什麼錯了。
任何形式的幫助將不勝感激。
嘗試調用通知編輯器(在第一個塊)刪除操作..我想,你編輯兩個單獨的首選項文件。 – 2013-04-22 17:54:27
嘗試以相同的方式並在相同的上下文中檢索SharedPrefences.Editor。 – hovanessyan 2013-04-22 17:55:08
@hovanessyan你有什麼我可以看的。我無法得到你。 – Anupam 2013-04-22 17:59:02