使用gson 将链表存储的优化转化:
private Gson gson = new Gson();
private void readStr(){
List<ContactsBeanInfo> contacts = null;
if (!TextUtils.isEmpty(str) && !init) {
contacts = gson.fromJson(str,
new TypeToken<List<ContactsBeanInfo>>() {}.getType());// 把JSON格式的字符串转为List
}
}
private void savaContacts() {
String list = gson.toJson(contactsList);
SharedPrefsUtil.putSetStringValue(mContext, SystemParamHelper
.getInstance().getAccountID() + SharedPrefsUtil.CONTACTS_DATA,
list);
SharedPrefsUtil.putSetBooleanValue(mContext, SystemParamHelper
.getInstance().getAccountID() + SharedPrefsUtil.INIT_CONTACTS,
false);
}
使用gson 将不需要排序子链表转化 主链表的一个字段进行存储;
GSON链接: https://pan.baidu.com/s/1pKQz367 密码: za9s