List of usage examples for android.content SharedPreferences getInt
int getInt(String key, int defValue);
From source file:Main.java
public static int getMsgFirstSyncKey(String targetId, Context context) { SharedPreferences preferences = context.getSharedPreferences("messageFirstSync" + targetId, Context.MODE_PRIVATE); return preferences.getInt("targetId", 0); }
From source file:Main.java
private static int getIntegerPreference(Context context, String key) { int value = -1; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); if (preferences != null) { value = preferences.getInt(key, -1); }/*from w w w . ja v a2 s .c om*/ return value; }
From source file:Main.java
/** * get int preferences//from w ww.ja v a2 s . c o m * * @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 = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); return settings.getInt(key, defaultValue); }
From source file:Main.java
public static int loadListPosition(Context context, String settings) { SharedPreferences pSharedPref = context.getSharedPreferences(settings, Context.MODE_PRIVATE); if (pSharedPref != null) { return pSharedPref.getInt(positionKey, 0); } else/* ww w. j ava2s . com*/ return 0; }
From source file:Main.java
public static void loadArray(Context mContext) { SharedPreferences mSharedPreference1 = PreferenceManager.getDefaultSharedPreferences(mContext); mDishLikeList.clear();// w w w . j a va 2 s . c o m int size = mSharedPreference1.getInt("Like_size", 0); for (int i = 0; i < size; i++) { mDishLikeList.add(mSharedPreference1.getString("Like_" + i, null)); } }
From source file:Main.java
public static boolean checkFirstStart(Context paramContext) { SharedPreferences time = paramContext .getSharedPreferences("collection_agent_" + paramContext.getPackageName(), 0); int flag = time.getInt("flag", 0); if (flag == 0) { return true; }/*from w w w.jav a 2 s . c o m*/ return false; }
From source file:Main.java
public static int getCount(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(REVIEW_PREFS, Context.MODE_PRIVATE); return sharedPreferences.getInt(KEY_COUNT, 0); }
From source file:Main.java
public static int getCallOnNum(Context context) { try {/*from w ww.j av a2 s .c om*/ SharedPreferences sharedPreferences = context.getSharedPreferences("com.cmmobi.icuiniao.systime", Activity.MODE_PRIVATE); return sharedPreferences.getInt("callonnum", -1); } catch (Exception e) { } return -1; }
From source file:Main.java
/** * Retrieve an integer value from the preferences. * * @param context to retrieve Default SharedPreferences. * @param key The name of the preference to retrieve. * @param value Value to return if this preference does not exist. * * @return Returns the preference value if it exists, or defValue. Throws * ClassCastException if there is a preference with this name that is not * a boolean.//from w w w . j a va2s .co m * * @throws ClassCastException * * @see {@link android.preference.PreferenceManager#getDefaultSharedPreferences(Context)}. */ public static int loadPrefs(Context context, String key, int value) { SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(context); return getPrefs.getInt(key, value); }
From source file:Main.java
/** * Returning the stored values in the shared preference with values provided * as parameters/*w w w . j a v a 2 s .c o m*/ * * @param context * @param key * @return */ public static final int getIntSharedPreference(Context context, String key) { if (context != null) { SharedPreferences Pref = context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE); int value = Pref.getInt(key, 0); return value; } else { return 0; } }