List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static String getCipher(Context context) { String aes = null;/*from w ww .j a v a2s .c o m*/ if (context != null) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); aes = settings.getString("cipher", ""); } return aes; }
From source file:Main.java
public static String getPreferenceString(Context context, String preferenceKey) { String preferenceValue;// ww w.j av a 2 s.c o m SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); preferenceValue = preferences.getString(preferenceKey, null); return preferenceValue; }
From source file:Main.java
/** * Check if app has been run once or not *//*from ww w. j a v a 2 s . c om*/ public static Boolean firstTimeRun(Context context) { SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context); return appPreferences.getBoolean("prefappfirstrun", true); }
From source file:Main.java
public static void saveLongValue(Context context, String key, Long value) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = prefs.edit();/*from w ww.j a va 2s .com*/ editor.putLong(key, value); editor.commit(); }
From source file:Main.java
public static boolean getBooleanFromDefaults(Context context, String key) { if (context != null) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); return sharedPreferences.getBoolean(key, false); } else/*ww w. jav a 2 s. c o m*/ return false; }
From source file:Main.java
public static void setUserName(final Context context, final String name) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putString(PREF_NAME, name).commit(); }
From source file:Main.java
public static void setRootEnabled(Context context, boolean isRoot) { SharedPreferences preferenceScreen = PreferenceManager.getDefaultSharedPreferences(context); preferenceScreen.edit().putBoolean("isRootEnabled", isRoot).apply(); }
From source file:Main.java
public static String getServerBaseAddress(Context context) { return PreferenceManager.getDefaultSharedPreferences(context).getString(KEY_SERVER_BASE_ADDRESS, ""); }
From source file:Main.java
public static boolean logout(Context context) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); sharedPref.edit().putString(PREF_KEY_THEME, "").apply(); return true;// w ww . jav a 2 s. co m }
From source file:Main.java
public static boolean getPrefMenlofont(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getBoolean(PREF_MENLO_FONT, true); }