List of usage examples for android.content SharedPreferences getInt
int getInt(String key, int defValue);
From source file:Main.java
public static int getIntValue(Context context, String key, int defValue) { SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE); return sp.getInt(key, defValue); }
From source file:Main.java
/** * get int preferences//ww w. j a va2 s . com * * @param context * @param key The name of the preference to retrieve * @param defaultValue Value to return if this preference does not exist * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with * this name that is not a int */ public static int getInt(Context context, String key, int defaultValue) { SharedPreferences settings = getDefaultPreferences(context); return settings.getInt(key, defaultValue); }
From source file:Main.java
public static int getPreference(Context context, String key, int defaultValue) { SharedPreferences pref = getPreferences(context); return pref.getInt(key, defaultValue); }
From source file:Main.java
public static int readInteger(Context context, String key, int defaultValue) { SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE); return pre.getInt(STORE_KEY_PREFIX + key, defaultValue); }
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
public static int getRoleFromPref(Context mContext) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mContext); int role = pref.getInt("userRole", -2); return role;//from w w w .ja va2 s . c om }
From source file:Main.java
/** * Get value by key in config/*w w w .j a v a 2 s . c om*/ * @param context context * @param key the key * @param defaultValue if can't find the value of key, will return default value * @return value */ public static int getInt(Context context, String key, int defaultValue) { SharedPreferences sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); return sp.getInt(key, defaultValue); }
From source file:Main.java
public static int getPreference(Context context, String key, int defaultValue) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getInt(key, defaultValue); }
From source file:Main.java
public static int getPrefInt(Context context, final String key, final int defaultValue) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getInt(key, defaultValue); }
From source file:Main.java
public static int fetchIntSharePref(Context context, String key) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getInt(key, 0); }