当我尝试使用shared preference
putStringSet
中保存数据时,此代码出错
请告诉我,我做错了。
我这样做:
public void onReceive(Context arg0, Intent arg1) {
String[][] my_date;
my_date = new String[][] {
{"14","26"},
{"12","16","24","27"},
{"17"},
{"8","13","18"},
{"14"},
{},
{"29"},
{"15","18"},
{},
{"2","3","6","8","23"},
{"4","6","24"},
{}
};
SharedPreferences pref = arg0.getSharedPreferences("MyPref", 0); // 0 - for private mode
SharedPreferences.Editor editor = pref.edit();
Set<String> myStrings = pref.**getStringSet**("my_date", new HashSet<String>());
myStrings.add("Another string");
editor.putStringSet("myStrings", myStrings);
editor.commit();
}