问题描述
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?
推荐答案
在第一个引用之后,它们在内存中.第一次检索特定的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的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!