List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
/** * Put a key-value into config// w w w. j a v a 2 s .c o m * @param context context * @param key the key * @param value the value */ public static void putInt(Context context, String key, int value) { SharedPreferences sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); SharedPreferences.Editor edit = sp.edit(); edit.putInt(key, value).commit(); }
From source file:Main.java
/** * Put a key-value into config// w w w . j ava 2 s. c om * @param context context * @param key the key * @param value the value */ public static void putString(Context context, String key, String value) { SharedPreferences sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); SharedPreferences.Editor edit = sp.edit(); edit.putString(key, value).commit(); }
From source file:Main.java
public static void setClickCount(Context context, int count) { SharedPreferences sd = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sd.edit(); editor.putInt(CLICK_COUTNT, count);/*from w w w. jav a 2 s. co m*/ editor.commit(); }
From source file:Main.java
public static void setSettingInt(final Context context, final String key, final int value) { SharedPreferences setting = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = setting.edit(); editor.putInt(key, value);/* ww w .j a v a2 s. com*/ editor.commit(); }
From source file:Main.java
public static void cacheFapisLoginUser(String token, Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences("configuration", 0); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString("token", token); editor.commit();//from www . j a va2 s . co m }
From source file:Main.java
public static boolean putString(Context context, String key, String values) { SharedPreferences setting = context.getSharedPreferences("login", context.MODE_PRIVATE); SharedPreferences.Editor editor = setting.edit(); editor.putString(key, values);//from w ww . ja va 2 s. com return editor.commit(); }
From source file:Main.java
public static void set(Context context, String pref, String value) { SharedPreferences settings = context.getSharedPreferences("defaultPreferences", 0); SharedPreferences.Editor editor = settings.edit(); editor.putString(pref, value);/*w ww . j a v a2 s. c om*/ // Commit the edits! editor.apply(); }
From source file:Main.java
public static void saveIp(Context context, String Ipname) { SharedPreferences preferences = context.getSharedPreferences("IP", Context.MODE_PRIVATE); SharedPreferences.Editor edit = preferences.edit(); edit.putString("ip", Ipname); edit.commit();//w ww .j a v a2 s . c o m }
From source file:Main.java
public static void deleteSharedPreferencesKey(Context context, String key) { SharedPreferences mySPrefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = mySPrefs.edit(); editor.remove(key);//w w w .j av a 2s . c om editor.apply(); }
From source file:Main.java
public static void setSettingString(final Context context, final String key, final String value) { SharedPreferences setting = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = setting.edit(); editor.putString(key, value);//from w w w .jav a 2s . c om editor.commit(); }