我有 ab ArrayList,其中包含 ArrayList,它们又包含列表。字符串之一和 View 之一。我如何将此根列表保存到共享首选项或任何其他位置?以下是概述:
MotherList
|
.
DaughterLists
/ \
/ \
ListOfViews ListOfStrings
.
.
最佳答案
使用共享首选项存储 Arraylist
SharedPreferences prefs=this.getSharedPreferences("yourPrefsKey",Context.MODE_PRIVATE);
Editor edit=prefs.edit();
Set<String> set = new HashSet<String>();
set.addAll(your Arraylist Name);
edit.putStringSet("yourKey", set);
edit.commit();
从共享首选项中检索 Arraylist
Set<String> set = prefs.getStringSet("yourKey", null);
List<String> sample=new ArrayList<String>(set);
关于java - 如何保存ArrayList <List>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36489221/