【发布时间】:2012-08-29 20:44:13
【问题描述】:
我想将 ArrayList 保存到 SharedPreferences 中,所以我需要将其转换为字符串并返回,这就是我正在做的:
// Save to shared preferences
SharedPreferences sharedPref = this.getPreferences(Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = this.getPreferences(Activity.MODE_PRIVATE).edit();
editor.putString("myAppsArr", myAppsArr.toString());
editor.commit();
我可以用String arrayString = sharedPref.getString("yourKey", null); 检索它,但我不知道如何将arrayString 转换回ArrayList。怎么办?
我的数组看起来像:
[item1,item2,item3]
【问题讨论】:
标签: java android string list arraylist