SharedPreferences

suggest change

Introduction

SharedPreferences provide a way to save data to disk in the form of key-value pairs.

Syntax

- public SharedPreferences.Editor edit()
- public boolean contains()
- public Map<String, ?> getAll()
- public boolean getBoolean(String key, 
                boolean defValue)
- public float getFloat(String key, 
                float defValue)
- public int getInt(String key, 
                int defValue)
- public long getLong(String key, 
                long defValue)
- public String getString(String key, 
                String defValue)
- public Set<String> getStringSet(String key, 
                Set<String> defValues)
- public void registerOnSharedPreferenceChangeListener (SharedPreferences.OnSharedPreferenceChangeListener listener)
- public void unregisterOnSharedPreferenceChangeListener (SharedPreferences.OnSharedPreferenceChangeListener listener)
- public void apply()
- public boolean commit()
- public SharedPreferences.Editor clear()
- public SharedPreferences.Editor putBoolean (String key, 
                boolean value)
- public SharedPreferences.Editor putFloat (String key, 
                float value)
- public SharedPreferences.Editor putInt (String key, 
                int value)
- public SharedPreferences.Editor putLong (String key, 
                long value)
- public SharedPreferences.Editor putString (String key, 
                String value)
- public SharedPreferences.Editor putStringSet (String key, 
                Set<String> values)
- public SharedPreferences.Editor remove (String key)

Parameters

Parameter | Details |

——— | —–– |

key | A non-null String identifying the parameter. It can contain whitespace or non-printables. This is only used inside your app (and in the XML file), so it doesn’t have to be namespaced, but it’s a good idea to have it as a constant in your source code. Don’t localize it. | defValue | All the get functions take a default value, which is returned if the given key is not present in the SharedPreferences. It’s not returned if the key is present but the value has the wrong type: in that case you get a ClassCastException. |

Remarks

Official Documentation

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


SharedPreferences:
* SharedPreferences

Table Of Contents
2 Gradle
5 Intent
13 SharedPreferences
17 Service
19 WebView
31 SQLite
35 Glide
37 Dialog
38 ACRA
44 Handler
53 Toast
63 Menu
65 Picasso
70 Volley
71 Widgets
78 Realm
90 Spinner
95 OkHttp
108 TextView
109 ListView
111 Loader
118 Xposed
119 Security
121 ImageView
123 Doze Mode
130 Drawables
131 Colors
134 Fresco
139 AdMob
145 Keyboard
146 Button
150 EditText
155 Vk SDK
163 ExoPlayer
169 XMPP
175 OpenCV
177 Threads
184 ORMLite
186 TabLayout
190 LruCache
192 Zip files
194 Fastlane
199 FileIO
202 Moshi
210 VideoView
216 Paint
218 ProGuard
226 CleverTap
228 ADB shell
229 Ping ICMP
230 AIDL
234 Context
240 JCodec
242 Okio
249 FuseView
254 Looper
261 Fastjson
263 Jackson
267 Smartcard