List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static void removeKey(String preName, Context context, String key) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit(); editor.remove(key);/* w w w .j a v a2s.com*/ editor.commit(); }
From source file:Main.java
public static void logOut(Context context) { SharedPreferences pref = context.getSharedPreferences(context.getPackageName() + "_preferences", 0); pref.edit().putString(ACCESS_TOKEN, "").putString(EXPIRES_IN, "").putString(UID, "").commit(); }
From source file:Main.java
public static void setConfig(Context context, String key, String value) { SharedPreferences sp = context.getSharedPreferences("money", Activity.MODE_PRIVATE); Editor editor = sp.edit(); editor.putString(key, value);/*from w ww. j av a2s . co m*/ editor.commit(); }
From source file:Main.java
public static void putSharedPreferencesBoolean(Context context, String key, boolean val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit(); edit.putBoolean(key, val); edit.commit();/*from www .jav a 2s .c o m*/ }
From source file:Main.java
public static SharedPreferences.Editor remove(Context context, String fileName, String name) { SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); return sharedPreferences.edit().remove(name); }
From source file:Main.java
public static void putSharedPreferencesString(Context context, String key, String val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit(); edit.putString(key, val); edit.commit();/*ww w .j av a2 s . c o m*/ }
From source file:Main.java
public static void putSharedPreferencesLong(Context context, String key, long val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit(); edit.putLong(key, val); edit.commit();//from w w w .j a v a 2 s . c o m }
From source file:Main.java
public static void putSharedPreferencesInt(Context context, String key, int value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit(); edit.putInt(key, value);// ww w .j a v a 2s.co m edit.commit(); }
From source file:Main.java
public static void putSharedPreferencesFloat(Context context, String key, float val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit(); edit.putFloat(key, val); edit.commit();/*from w ww. j ava 2 s. c om*/ }
From source file:Main.java
public static void saveLogin(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHERED_NAME, Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean(SHARED_KEY_IS_LOGGED, true).commit(); }