数据库SQLite 数据大量存储 和快速读取 链表查询的优化 使用gosn

xiaoxiao2021-02-28  73

使用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

转载请注明原文地址: https://www.6miu.com/read-63795.html

最新回复(0)