List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static void setFirstByTag(String tag, Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean(tag, false);/*from w w w. ja v a 2s. c om*/ editor.commit(); }
From source file:Main.java
public static boolean isFirstByTag(String tag, Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); boolean flag = sp.getBoolean(tag, true); return flag;//from ww w. j a va2s . c o m }
From source file:Main.java
public static void setLogText(Context context, String text) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sp.edit(); editor.putString("log_text", text); editor.commit();//from ww w .j a v a2 s . c om }
From source file:Main.java
public static String readFromPrefs(Context context, String key) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getString(key, null); }
From source file:Main.java
public static void putInt(Context context, String key, int value) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.edit().putInt(key, value).apply(); }
From source file:Main.java
public static void setArea(String area, Context ctx) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ctx); SharedPreferences.Editor editor = preferences.edit(); editor.putString("selectedArea", area); editor.commit();/*from w w w . j a v a 2 s . c om*/ }
From source file:Main.java
public static int getIntSPR(String key, Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getInt(key, 0); }
From source file:Main.java
private static void save(Context context, String key, String value) { Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putString(key, value);/* w w w . jav a 2s .c o m*/ editor.commit(); }
From source file:Main.java
public static void logOutAllUsers(Context context) { PreferenceManager.getDefaultSharedPreferences(context).edit().remove(LOGGED_IN_USER_PREFERENCE_KEY) .commit(); }
From source file:Main.java
public static void putLong(Context context, String key, long value) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.edit().putLong(key, value).apply(); }