Answers for "what kind of data types can be saved in sharedpreferences"

1

get preference value android

boolean mBoolean = PreferenceManager.getDefaultSharedPreferences(yourContext).getBoolean(key, defaultValue); //getBoolean will return defaultValue is key isn't found
//you can also use getInt, getFloat, getLong, getString, getStringSet and change the variable type, of course
Posted by: Guest on March-16-2020
0

refresh sharedpreferences going back java

getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
Posted by: Guest on September-19-2020
0

set preference value android

boolean committed = PreferenceManager.getDefaultSharedPreferences(yourContext).edit().putBoolean(key, mValue).commit();
//you can also use putInt, putFloat, putLong, putString, putStringSet and change the value of mValue
//committed is true if everything went alright, false if there was an error
Posted by: Guest on March-16-2020

Code answers related to "what kind of data types can be saved in sharedpreferences"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language