Answers for "how to use sharedpreferences"

4

android sharedpreferences

SharedPreferences sharedPref = getSharedPreferences("name", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("key", "Value");
editor.commit();
Posted by: Guest on November-07-2020
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

Code answers related to "how to use sharedpreferences"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language