Example usage for android.content SharedPreferences getInt

List of usage examples for android.content SharedPreferences getInt

Introduction

In this page you can find the example usage for android.content SharedPreferences getInt.

Prototype

int getInt(String key, int defValue);

Source Link

Document

Retrieve an int value from the preferences.

Usage

From source file:Main.java

public static int getMode(String txt, Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(txt, Context.MODE_PRIVATE);
    return sp.getInt(key, -1);
}

From source file:Main.java

public static int getInt(String key, int defValue, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    return sp.getInt(key, defValue);
}

From source file:Main.java

public static int getMinutes(SharedPreferences prefs) {
    if (prefs.contains(PREFS_MINS)) {
        return prefs.getInt(PREFS_MINS, DEFAULT_MINS);
    } else {//from  ww  w  . j a va2 s .c om
        return DEFAULT_MINS;
    }
}

From source file:Main.java

public static int getNotReadCount(Context context) {
    SharedPreferences spf = context.getSharedPreferences("msg", Context.MODE_PRIVATE);
    return spf.getInt("count", 0);
}

From source file:Main.java

/**
 * read int value from preference memory
 *//*  w  ww  .j  a  va 2  s  .  c om*/
public static int getInt(Context context, String key, int defValue) {
    if (context == null)
        return defValue;
    SharedPreferences settings = context.getSharedPreferences(PREF_NAME, 0);
    return settings.getInt(key, defValue);
}

From source file:Main.java

public static int getDayNightMode(Context context) {
    SharedPreferences sharedPreferences = getSharedPreferences(context);
    return sharedPreferences.getInt("SUN_NIGHT_MODE", THEME_SUN);
}

From source file:Main.java

public static int getCountryToIdx(Context context) {
    SharedPreferences pref = context.getSharedPreferences(CURRENCY_PREF_NAME, 0);
    return pref.getInt(COUNTRY_TO_IDX, 0);
}

From source file:Main.java

public static int getInt(Context context, final String key, int defaultValue) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    return prefs.getInt(key, defaultValue);
}

From source file:Main.java

public static int getCountryFromIdx(Context context) {
    SharedPreferences pref = context.getSharedPreferences(CURRENCY_PREF_NAME, 0);
    return pref.getInt(COUNTRY_FROM_IDX, 0);
}

From source file:Main.java

public static int getInt(Context ctx, String key, int defaultValue) {
    SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    return sp.getInt(key, defaultValue);
}