Dave's Brain

Browse - Programming Tips - Android: What is the size limit for a value in Preferences and SharedPreferences

Date: 2018mar14
OS: Android
Language: Java

Q.  Android: What is the size limit for a value in Preferences and SharedPreferences

A.

Preferences - a limit of 8K for each value
SharedPreferences - no limit (except size of a Java String - which can be huge)

Its odd that the limits are so different for things that are so similar but there you are.
However its bad practice to keep really big things in SharedPreferences.

References:

https://developer.android.com/reference/java/util/prefs/Preferences.html#MAX_VALUE_LENGTH

https://developer.android.com/reference/android/content/SharedPreferences.html

https://stackoverflow.com/questions/8516812/shared-preferences-max-length-of-a-single-value

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.