List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static void setSharedPreferences(Context context, String key, String value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putString(HORSEPUSH + key, value); editor.commit();/* www .java 2s .c om*/ }
From source file:Main.java
public static void putString(Context context, String key, String value) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); Editor editor = sp.edit(); editor.putString(key, value);/*from ww w . j a va 2 s . c om*/ editor.commit(); }
From source file:Main.java
public static void storeBoolianSharePref(Context context, String key, Boolean value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(key, value);// w w w .j a v a 2 s . c om editor.apply(); }
From source file:Main.java
public static void putFloat(Context context, String key, float value) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); Editor editor = sp.edit(); editor.putFloat(key, value);// w w w. ja va 2 s . com editor.commit(); }
From source file:Main.java
public static void setPosterToastFlag(Context context, boolean flag) { SharedPreferences sp = context.getSharedPreferences("poster_toast", Activity.MODE_PRIVATE); SharedPreferences.Editor tor = sp.edit(); tor.putBoolean("toast_flag", flag); tor.commit();//from www . j a v a2s . c o m }
From source file:Main.java
public static void storeInSharedPreference(String key, String value, Context context) { SharedPreferences preferences = context.getSharedPreferences("TOKEN", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString(key, value);/* w w w . j a va 2s . c o m*/ editor.commit(); }
From source file:Main.java
public static void storeIntSharePref(Context context, String key, int value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putInt(key, value);/*from ww w . j a v a 2 s . c o m*/ editor.apply(); }
From source file:Main.java
public static void storeLongSharePref(Context context, String key, long value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putLong(key, value);/*from w w w. j a va2 s . co m*/ editor.apply(); }
From source file:Main.java
public static void setWebviewHelpStatus(Context context, boolean status) { SharedPreferences sp = context.getSharedPreferences("webview_help", Activity.MODE_PRIVATE); SharedPreferences.Editor tor = sp.edit(); tor.putBoolean("webview_help", status); tor.commit();//from w w w. j a va 2s. co m }
From source file:Main.java
public static void remove(Context context, String key) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); Editor editor = sp.edit(); editor.remove(key);/*from w ww .j a v a 2 s.c o m*/ editor.commit(); }