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 void setThemePackageName(Context context, String packageName) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("themePackageName", packageName);
    editor.commit();/*ww  w.j a v  a  2s  . c o  m*/
}

From source file:Main.java

public static void putUserPic(Context context, String city) {
    SharedPreferences preferences = context.getSharedPreferences(USERPIC, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, city).commit();
}

From source file:Main.java

public static void putString(Context context, String key, String values) {
    SharedPreferences sp = context.getSharedPreferences("7Yan", context.MODE_PRIVATE);
    sp.edit().putString(key, values).commit();
}

From source file:Main.java

public static boolean isPassphraseInitialized(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_NAME, 0);
    return preferences.getBoolean("passphrase_initialized", false);
}

From source file:Main.java

public static void putBoolean(Context context, String key, boolean value) {
    SharedPreferences sp = context.getSharedPreferences("tron", Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, value).commit();
}

From source file:Main.java

public static void putInt(Context mContext, String key, int values) {
    SharedPreferences sp = mContext.getSharedPreferences(SHARE_NAME, Context.MODE_PRIVATE);
    sp.edit().putInt(key, values).commit();
}

From source file:Main.java

public static void putCity(Context context, String city) {
    SharedPreferences preferences = context.getSharedPreferences(CITY, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, city).commit();
}

From source file:Main.java

public static void putLiveType(Context context, String type) {
    SharedPreferences preferences = context.getSharedPreferences(LIVE_TYPE, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, type).commit();
}

From source file:Main.java

public static void putLNG(Context context, String city) {
    SharedPreferences preferences = context.getSharedPreferences(LNG, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, city).commit();
}

From source file:Main.java

public static void setMapHintVisibility(Context context, boolean visible) {
    SharedPreferences sharedPref = context.getSharedPreferences(KEY_SHOW_MAP_HINT, Context.MODE_PRIVATE);
    sharedPref.edit().putBoolean(KEY_SHOW_MAP_HINT, visible).apply();
}