存储一组字符串的最佳方法是什么
What is the best way to store a set of strings
所以我有一组字符串:
public Set<String> favs = new HashSet<>();
我稍后在activity中添加。但是,我希望能够使用一个来源读取和写入来自其他活动的这些字符串,用于所有数据我添加了一些图形来尝试更好地解释我的意思。以这种方式存储我的个人字符串的最佳方式是什么?
我希望数据在关闭应用程序时继续存在。
估计最多会有 30 件物品。
数据将来自内部输入的数据。
考虑使用共享偏好。
public void setValue(Set<String> stringSet) {
getSharedPreferences(getClass().getSimpleName(), Context.MODE_PRIVATE).edit().putStringSet("key",stringSet).comit();
}
所以我有一组字符串:
public Set<String> favs = new HashSet<>();
我稍后在activity中添加。但是,我希望能够使用一个来源读取和写入来自其他活动的这些字符串,用于所有数据我添加了一些图形来尝试更好地解释我的意思。以这种方式存储我的个人字符串的最佳方式是什么?
我希望数据在关闭应用程序时继续存在。 估计最多会有 30 件物品。 数据将来自内部输入的数据。
考虑使用共享偏好。
public void setValue(Set<String> stringSet) {
getSharedPreferences(getClass().getSimpleName(), Context.MODE_PRIVATE).edit().putStringSet("key",stringSet).comit();
}