Example usage for android.content Context getSharedPreferences

List of usage examples for android.content Context getSharedPreferences

Introduction

In this page you can find the example usage for android.content Context getSharedPreferences.

Prototype

public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);

Source Link

Document

Retrieve and hold the contents of the preferences file, returning a SharedPreferences through which you can retrieve and modify its values.

Usage

From source file:Main.java

public static String getUserCidiograph(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO_OTHER, Context.MODE_PRIVATE);
    String userLevel = preferences.getString(USER_CIDIOGRAPH, "");
    return userLevel;
}

From source file:Main.java

public static String getUserDeposit(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO_OTHER, Context.MODE_PRIVATE);
    String userLevel = preferences.getString(USER_DEPOSIT, "");
    return userLevel;
}

From source file:Main.java

public static int getTextSizePrefs(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
    return sp.getInt(key, 2);

}

From source file:Main.java

public static void cacheFlyDuration(Context context, long time) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
    sp.edit().putLong(KEY_BD, time).commit();
}

From source file:Main.java

public static int getCount(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(DOWN_COUNT, Context.MODE_PRIVATE);
    int count = preferences.getInt(DOWN_COUNT_KEY, 0);
    return count;
}

From source file:Main.java

public static String getStringPrefs(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE);
    return sp.getString(key, "");

}

From source file:Main.java

public static void cacheBalloonCount(Context context, int count) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
    sp.edit().putInt(KEY_BC, count).commit();
}

From source file:Main.java

public static String getUserId(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE);
    String userIcon = preferences.getString(USER_ID, "");
    return userIcon;
}

From source file:Main.java

/**
 * Method to get the last assumed Stage of the active session 
 * //ww w .j  ava2 s  .c  o m
 * @param context Context
 * @return Last assumed Stage of the active session 
 */
public static int getActiveSessionStage(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);

    return prefs.getInt(PREFS_KEY_STAGE, 0);
}

From source file:Main.java

public static String getStoredToken(Context caller) {
    SharedPreferences prefs = caller.getSharedPreferences(AUTH_PREFS, 0);
    return prefs.getString(PREF_TOKEN, null);
}