I have three activities, A, B & C. Where A is a splash Activity and B Contains Login screen which consist of user Id and Password Text Field and one button to login. When I
This is the best way to use Shared preference just call this method
Store shared preference
public static void setDefaults(String key, String value, Context context) {
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(key, value);
editor.commit();
}
Call this method and pass argument like this
Classname.setsetDefaults("key","Value",context);
Get Shared Value
public static String getDefaults(String key, Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
return preferences.getString(key, null);
}
Call this method And pass key
ClassName.getDefaults("Key",Context);