List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static long getPrefLong(Context context, final String key, final long defaultValue) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getLong(key, defaultValue); }
From source file:Main.java
public static boolean getSharedPreferencesBoolean(Context context, String key, boolean _default) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getBoolean(key, _default); }
From source file:Main.java
public static String getHistoricValue(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getString("historic_range", "week"); }
From source file:Main.java
public static float getPrefFloat(Context context, final String key, final float defaultValue) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getFloat(key, defaultValue); }
From source file:Main.java
public static String getString(Context context, String key, String defaultValue) { try {//from ww w . j a v a 2s .c o m SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getString(key, defaultValue); } catch (Exception e) { e.printStackTrace(); return defaultValue; } }
From source file:Main.java
private static long getLongPreference(Context context, String key) { long value = -1; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); if (preferences != null) { value = preferences.getLong(key, -1); }/*from ww w. j av a 2s . com*/ return value; }
From source file:Main.java
public static String getToken(Context context) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); return sharedPreferences.getString("token_preference", ""); }
From source file:Main.java
public static String getServerPort(Context context) { return PreferenceManager.getDefaultSharedPreferences(context).getString(KEY_SERVER_PORT, ""); }
From source file:Main.java
public static String getUserId(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getString(PREF_ID, null); }
From source file:Main.java
public static String readRecords(int gameId, String key) { SharedPreferences mPerferences = PreferenceManager.getDefaultSharedPreferences(mContext); return mPerferences.getString(key, ""); }