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 getNumTickers(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return sharedPreferences.getInt(PREF_NUM_TICKERS, 0);
}

From source file:Main.java

public static int getIntFromSharePrefs(Context context, String fileName, String key, int defaultValue) {
    if (context == null) {
        return defaultValue;
    }//from   ww  w.j av  a 2 s  .c o  m
    SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preferences.getInt(key, defaultValue);
}

From source file:Main.java

public static int getIntPreference(Context context, String key, int def) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getInt(key, def);
}

From source file:Main.java

public static boolean shouldShowTutorial(Context context, String tutorialName, int limit) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    int shown = prefs.getInt("tutorial" + tutorialName, 0);
    prefs.edit().putInt("tutorial" + tutorialName, shown + 1).apply();
    return limit == shown;
}

From source file:Main.java

public static int getLastForumPageSaved(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    int forumPageNum = prefs.getInt(PREF_LAST_FORUM_PAGE_SAVED, -1);
    return forumPageNum;
}

From source file:Main.java

public static int getInt(String fileName, Context context, String keyId, int defaultValue) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return sharedPreferences.getInt(keyId, defaultValue);
}

From source file:Main.java

public static int getAlarmRecord(Context context) {
    SharedPreferences sh = context.getSharedPreferences("alarm_record", Activity.MODE_PRIVATE);
    return sh.getInt("alarmRecord", -1);
}

From source file:Main.java

static int loadLastPhoneCount(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(AGE_PREFERENCES, Context.MODE_PRIVATE);

    return prefs.getInt(AGE_LAST_PHONE_COUNT, -1);
}

From source file:Main.java

public static int getIntSp(Context context, String key) {
    SharedPreferences mySharedPreferences = context.getSharedPreferences("avalon", Activity.MODE_PRIVATE);
    return mySharedPreferences.getInt(key, 5);
}

From source file:Main.java

public static int getUserId(Context context) {
    int userId = 0;
    if (context != null) {
        SharedPreferences sp = context.getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        userId = sp.getInt("USERID", 0);
    }//  w ww.  ja va 2s.c  o m
    return userId;

}