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 getInt(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 restoreDistanceTravelled(Context context) {
    SharedPreferences sharedPref = context.getSharedPreferences("Distance", Context.MODE_PRIVATE);
    return sharedPref.getInt("distance", 0);
}

From source file:Main.java

public static int getMaxIndex(Context mContext) {
    SharedPreferences settings = mContext.getSharedPreferences("clock", Context.MODE_PRIVATE);
    return settings.getInt(MAX_INDEX, 0);
}

From source file:Main.java

public static int loadIntSavedPreferences(String key, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences(sharedPrefsFile, Context.MODE_PRIVATE);
    int name = sp.getInt(key, -1);
    return name;/*from   ww w .  j  a  va  2 s .c o m*/
}

From source file:Main.java

public static int readSize(Context context) {
    SharedPreferences sp = context.getSharedPreferences("setSizeData", Context.MODE_PRIVATE);
    int size = sp.getInt("size", 2);
    return size;//from ww  w.j a v  a  2 s.c o  m
}

From source file:Main.java

public static int getSettingInt(final 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 loadActivityStatus(Context context) {
    SharedPreferences pref = context.getSharedPreferences("ActivityStatus", Context.MODE_PRIVATE);
    return pref.getInt("activity_status", ERROR_STATUS);
}

From source file:Main.java

/*********************
 * get shared preferences in int/*from  w ww .j  a  va2  s .  c o m*/
 ***********************/
public static int getPreferencesInteger(Context con, String key) {
    SharedPreferences sharedPreferences = con.getSharedPreferences("prefs_login", 0);
    int value = sharedPreferences.getInt(key, 0);
    return value;

}

From source file:Main.java

public static int readPreferenceFile(Context context, String filename, String name) {
    SharedPreferences preference = context.getSharedPreferences(filename, Context.MODE_PRIVATE);
    int num = preference.getInt(name, 0);
    return num;/*  w  w w .ja  va 2 s  . c  o m*/
}

From source file:Main.java

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