我无法从应用程序点击事件中删除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