I fully appreciate dumping lots of data into the preferences is totally inappropriate, but my requirement is not that great, but large enough (potentially 500-5000 bytes) where I've no idea whether it's appropriate or not. The docs do not help. http://developer.android.com/reference/android/content/SharedPreferences.Editor.html
I've searched the net and Stackoverflow and can't find a definitive answer on: a) what the actual limit is, based on the underlying architecture b) what the practical limit is, based on performance (I find writing even short pref values can take a few seconds, but I suspect that's just a flash write delay)
Would appreciate clarification.
SharedPreferences are not intended to store a lot of data, there is no limit per se (since it is an xml file), but for larger sets of data, I would suggest using Room (or SQLite for the older projects).
A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them. Each SharedPreferences file is managed by the framework and can be private or shared. This page shows you how to use the SharedPreferences APIs to store and retrieve simple values.
Android App Development for BeginnersShared Preferences allow you to save and retrieve data in the form of key,value pair. In order to use shared preferences, you have to call a method getSharedPreferences() that returns a SharedPreference instance pointing to the file that contains the values of preferences.
Yes you can maintain as many shared preference files for an app as you can.
All shared prefs are stored in /data/data/[package name]/shared_prefs/[app name].xml, so i think there's no limit based on architecture.
I don't know practical limit but I think it's enough for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With