读取SharedPreferences的速度 [英] Read speed of SharedPreferences

查看:235
本文介绍了读取SharedPreferences的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SharedPreferences有多快?有没有一种方法可以将它们存储在内存中以进行阅读?我需要查询ListView的少量数据才能显示每个单元格,并且我担心对闪存的调用太慢.我不担心写入速度,因为写入很少发生.我正在考虑仅使用JSON对象而不是SharedPreferences来保留数据.有什么想法吗?

How fast are SharedPreferences? Is there a way to put them in memory for reading? I have a small amount of data that a ListView has to query to display each cell, and I'm worried that a call to flash memory will be too slow. I'm not worried about write speed, as writes will happen infrequently. I'm considering just using a JSON object to persist the data instead of SharedPreferences. Any thoughts?

推荐答案

有没有一种方法可以将它们存储在内存中以供阅读?

Is there a way to put them in memory for reading?

在第一个引用之后,它们在内存中.第一次检索特定的SharedPreferences(例如PreferenceManager.getDefaultSharedPreferences())时,数据是从磁盘加载的,并保留在周围.

They are in memory, after the first reference. The first time you retrieve a specific SharedPreferences (e.g., PreferenceManager.getDefaultSharedPreferences()), the data is loaded from disk, and kept around.

这篇关于读取SharedPreferences的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆