SharedPreferences
有多快?有没有办法将它们放在内存中以供阅读?我有少量数据 ListView
必须查询以显示每个单元格,我担心对闪存的调用会太慢。我不担心写入速度,因为写入很少发生。我正在考虑只使用 JSON 对象而不是 SharedPreferences
来保存数据。有什么想法吗?
最佳答案
Is there a way to put them in memory for reading?
它们在内存中,在第一次引用之后。第一次检索特定的 SharedPreferences
(例如,PreferenceManager.getDefaultSharedPreferences()
)时,数据会从磁盘加载并保留。
关于android - SharedPreferences 的读取速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19148282/