Skip to content Skip to sidebar Skip to footer

Set Default Values For The Sharedpreferences For The Whole Aplication

I have the application with coding key, that should be visible from all parts of the application. It has to have a default value and an ability to be changed from one of the activi

Solution 1:

Let's say this is your shared preferences:

SharedPreferencessharedPreferences= PreferenceManager.getDefaultSharedPreferences(getContext());

you can set the default value like this:

Stringusername= sharedPreferences.getString("USER_NAME", "DEFAULT_VALUE");

Post a Comment for "Set Default Values For The Sharedpreferences For The Whole Aplication"