从SharedPreferences中删除ArrayList

时间:2015-12-27 11:38:19

标签: java android arraylist

我已使用以下代码将ArrayList存储在SharedPreferences中:

ArrayList<String> list1 = qarrayoff; // fetch the data
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
SharedPreferences.Editor edit = prefs.edit();
edit.putStringSet("SAVEDATA", new HashSet<String>(list1));
edit.commit();

现在我要删除ArrayList中存储的SharePreferences。怎么做?

1 个答案:

答案 0 :(得分:1)

您可以使用此代码片段实现它:

edit.remove("SAVEDATA"); 
edit.commit();