public static void addPromocodeString(String aCode) {
SharedPreferences.Editor editor = mActivity.getSharedPreferences(
"NunAttack", 0).edit();
SharedPreferences Prefs = mActivity.getSharedPreferences("NunAttack", 0);
Set<String> SavedCodes = new HashSet<String>();
SavedCodes = Prefs.getStringSet("savedCodesList", null);
if (editor != null) {
SavedCodes.add(aCode);
editor.putStringSet("savedCodesList", SavedCodes);
editor.commit();
}
}
上面的是android3.0以后用SharedPreferences 里面新添的方法getStringSet和putStringSet,谁知道在android3.0以前的,这段代码要怎么转换啊!
------解决思路----------------------
把set转化成字符串再存进去
------解决思路----------------------
百度了下 将set转换成string 用特殊字符隔开 LZ可以试试
可参见 http://www.cnblogs.com/tilltheendwjx/archive/2012/03/15/2477532.html