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 getPubMod(String contactID, Context context) {
    SharedPreferences prefs = context.getSharedPreferences(contactID, Context.MODE_PRIVATE);

    String pubMod = prefs.getString(PREF_PUBLIC_MOD, DEFAULT_PREF);

    return pubMod;
}

From source file:Main.java

public static SharedPreferences getPref(Context context, String fileName) {
    return context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
}

From source file:Main.java

public static String getPubExp(String contactID, Context context) {
    SharedPreferences prefs = context.getSharedPreferences(contactID, Context.MODE_PRIVATE);

    String pubExp = prefs.getString(PREF_PUBLIC_EXP, DEFAULT_PREF);

    return pubExp;
}

From source file:Main.java

public static boolean isControllerEnabled(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);

    // By default, when first time used, status is enabled
    return prefs.getBoolean(PREFS_CONTROLLER_STATUS, true);

}

From source file:Main.java

public static void storeInSharedPreference(String key, String value, Context context) {
    SharedPreferences preferences = context.getSharedPreferences("TOKEN", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(key, value);//  ww  w. j  a  v a  2 s  .c  o  m
    editor.commit();
}

From source file:Main.java

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

From source file:Main.java

public static void setSamsungESDKEnabled(Context context, Boolean value) {
    Editor edit = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit();
    edit.putBoolean(SAMSUNG_ESDK, value);
    edit.commit();//from w w  w .j av  a  2  s  .c  o m
}

From source file:Main.java

public static boolean getModeResult(Context context) {

    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);

    if (sp.getBoolean("nightState", false)) {
        return true;
    } else {/* ww  w .  j  av a 2 s.  co  m*/
        return false;
    }
}

From source file:Main.java

public static long getNotificationTime(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(NOTIFICATION_TIME_SHARED, 0);
    return preferences.getLong(NOTIFICATION_TIME, 0);
}

From source file:Main.java

public static int getInt(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("zexu", Context.MODE_PRIVATE);
    return sp.getInt(key, 0);
}