简体   繁体   English

共享偏好保存了多少数据?

[英]How much data does Shared Preference hold?

my question is how much data does Shared Preference take from device?我的问题是共享首选项从设备中获取了多少数据? I'm aware Shared Preference is used for small bits of data such as ints, strings etc but how much data does an int take from the device when stored in Shared Preferences?我知道共享首选项用于少量数据,例如整数、字符串等,但是当存储在共享首选项中时,int 从设备中获取了多少数据? Thanks谢谢

I'm aware Shared Preference is used for small bits of data such as ints, strings etc but how much data does an int take from the device when stored in Shared Preferences我知道共享首选项用于少量数据,例如整数、字符串等,但是当存储在共享首选项中时,int 从设备中获取了多少数据

There's no hard limit.没有硬限制。 The main reason it is not recommended to use SharedPreferences in place of the database is mainly the performance -> shared preferences data is keept in ordinary flat XML file which lacks all the features SQLite offers.不建议使用 SharedPreferences 代替数据库的主要原因主要是性能 -> 共享首选项数据保存在普通的平面 XML 文件中,该文件缺乏 SQLite 提供的所有功能。 Also the whole XML file is read into memory so if you grow it too much (but rather MB than KBs) then you may face OutOfMemory on some devices with smaller heap.此外,整个 XML 文件都被读入内存,因此如果它增长太多(而不是 MB 而不是 KB),那么在某些堆较小的设备上可能会遇到 OutOfMemory。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM