Android的多少共享preferences文件(S)?文件、Android、preferences

2023-09-04 05:46:02 作者:失忆の鱼

我注意到,当我打电话的共享preferences文件,我必须提供的文件的字符串名称的名字。这是否意味着我可以有多个共享preferences文件?

I notice that when I call sharedpreferences file, I have to supply the name of the string name of the file. Does that mean that I can have multiple shared preferences files?

其次,如果我想(使用带有许多列的SQL数据库,而不是)来存储多个值可能我在理论上有多个共享preferences文件,其中每个元素都是一个键,值对,并从价值第一个文件是一个关键,第二个文件,并从第二个文件返回的值是一个关键的第三个文件...返回更多,更具体的信息(albiet低效)

Secondly, if I wanted to store multiple values (instead of using an sql database with many columns) could I theoretically have multiple sharedpreferences files, where each element is a key, value pair, and the value from the first file is a key to the second file, and the value returned from the second file is a key to the third file... to return more and more specific information (albiet inefficiently)

是否有任何I / O限制的共享preferences,如SQL数据库?

Are there any I/O limits to sharedpreferences, such as with SQL databases?

推荐答案

您共享preferences都存储在

Your shared preferences are stored inside

/data/data/package.name/shared_prefs/prefsname.xml

的共享preferences类只是一个XML数据解析器/写器。

The SharedPreferences class is just an "xml" data parser/writer.

我不认为有任何具体的限制,但考虑使用SQLlite这是更快(甚至1000倍倍),并提供更方便的选择/排序是交易型的同时,分享preS是有用的只是存储一切用户的选择一样,我会看看其他地方。

I don't think there are any specific limit but consider using SQLlite which is much faster (even 1000x times more) and provides easier select/sort being transaction friendly at the same time, sharedpres are useful just for storing user options for everything else i would look elsewhere.

顺便说一句,我不知道使用SQLite任何限制,如果超过最大数据库端,你可以随时使用附加子句中使用更多的数据库在同一驯服(如果你有这么多的数据,以达到SQLite的限制比XML /共享preferences是不适合你的话)

BTW i don't know any limit with SQLITE, if you exceed maximum DB side you can always use "ATTACH" clause to use more DB at the same tame (and if you have so much data to reach SQLite limits than XML / SharedPreferences is not for you at all)