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 getCurrentAppCatalog(Context context) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    int newD = sp.getInt("currentAppCatalog", -1);
    return newD;/*from  w  ww  .  java 2s .  c o  m*/
}

From source file:Main.java

public static void appUsageNumber(Context context) {
    SharedPreferences settings = context.getSharedPreferences("Settings", Context.MODE_PRIVATE);
    Integer number = settings.getInt("usage_num", 0);

    settings.edit().putInt("usage_num", number + 1).commit();
}

From source file:Main.java

public static void saveAlarmRecord(Context context) {
    SharedPreferences sh = context.getSharedPreferences("alarm_record", Activity.MODE_PRIVATE);
    int i = sh.getInt("alarmRecord", -1);
    Log.i(">>>>>>>>>>>>>", i + ">>>>>>>>");

    sh.edit().putInt("alarmRecord", ++i).commit();
}

From source file:Main.java

public static int getInt(Context context, String key, int defValue) {
    SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    return sp.getInt(key, defValue);
}

From source file:Main.java

/**
 * Clears all messages.//from ww  w  .  j a  v a2  s.  c o  m
 * 
 * @param context The application context.
 * @return The number of messages cleared.
 */
public static int clearMessages(Context context) {
    SharedPreferences sp = context.getSharedPreferences("messages", Context.MODE_PRIVATE);
    int messages = sp.getInt("messages", 0);
    sp.edit().putInt("messages", 0).commit();
    return messages;
}

From source file:Main.java

public static int getInt(Context context, String key) {
    SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    int value = shared.getInt(key, 0);
    return value;
}

From source file:Main.java

/**
 * Stores the given message.//from   ww  w.  ja va2  s  .c o  m
 * 
 * @param context The application context.
 * @param message The message to store.
 * @return The number of total message including the stored one.
 */
public static int storeMessage(Context context, String message) {
    SharedPreferences sp = context.getSharedPreferences("messages", Context.MODE_PRIVATE);
    int messages = sp.getInt("messages", 0) + 1;
    sp.edit().putInt("messages", messages).putString("last", message).commit();
    return messages;
}

From source file:Main.java

public static int readInt(Context context, String fileName, String k) {
    SharedPreferences preference = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preference.getInt(k, 0);
}

From source file:Main.java

public static int readInt(Context context, String fileName, String k, int defv) {
    SharedPreferences preference = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preference.getInt(k, defv);
}

From source file:Main.java

public static Integer getActiveAccountTeamID(final Context context) {
    SharedPreferences sp = getSharedPreferences(context);
    return hasActiveAccount(context) ? sp.getInt(makeAccountSpecificPrefKey(context, PREFIX_PREF_TEAM_ID), -1)
            : null;// w  w w.  j  a v a2  s  .c om
}