How many Shared Preferences is too many?
I am writing a game and storing almost all active game data (stats, location etc...) in shared preferences.
This will, when all is said and done result in over 100 shared preferences used by my game. Of course the majority of those stored values are small integers or Boolean.
Since I don't need to do any sorting on the stored data, I don't really see a need to use a database.... unless there is some distinct advantage that I am not aware of.
Is the开发者_如何学Cre any reason why Shared Preferences should NOT be used in this way? Performance issues? Data Integrity issues? Anything?
Thanks in advance!
If the values remain small, and you don't need them to be structured (like if you have user profiles or something), then Shared Preferences should be just fine. 100 ints only amounts to 400 bytes, so even if the Shared Preferences were stored in memory, it's not a big deal.
There is no limit on the number of shared preferences (except for storage space), but these are currently written as a single XML file for the entire shared preference object, so you don't want to go crazy with how much you put there. 100 preferences shouldnt be an issue, and it allows a quicker and simpler access to data compared to databases or flat files etc.
It is actually an xml file. In your case, there is certainly no problem for your concerns.
精彩评论