Get Preference Value Android

[Solved] Get Preference Value Android | Kotlin - Code Explorer | yomemimo.com
Question : get preference value android

Answered by : fede

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

Source : | Last Update : Mon, 23 Mar 20

Question : set preference value android

Answered by : fede

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

Source : | Last Update : Mon, 23 Mar 20

Answers related to get preference value android

Code Explorer Popular Question For Kotlin