Example usage for android.content SharedPreferences getString

List of usage examples for android.content SharedPreferences getString

Introduction

In this page you can find the example usage for android.content SharedPreferences getString.

Prototype

@Nullable
String getString(String key, @Nullable String defValue);

Source Link

Document

Retrieve a String value from the preferences.

Usage

From source file:Main.java

/**
 * This function returns a hashmap which contains the colors for each face of the cube
 *//*from w  w  w  . ja  va 2 s  .c  om*/
public static HashMap<Character, Integer> getColorLetterHashMap(SharedPreferences sp) {
    HashMap<Character, Integer> hashMap = new HashMap<>(7);
    hashMap.put('Y', Color.parseColor("#" + sp.getString("cubeDown", "FDD835")));
    hashMap.put('R', Color.parseColor("#" + sp.getString("cubeRight", "EC0000")));
    hashMap.put('G', Color.parseColor("#" + sp.getString("cubeFront", "02D040")));
    hashMap.put('B', Color.parseColor("#" + sp.getString("cubeBack", "304FFE")));
    hashMap.put('O', Color.parseColor("#" + sp.getString("cubeLeft", "FF8B24")));
    hashMap.put('W', Color.parseColor("#" + sp.getString("cubeTop", "FFFFFF")));
    hashMap.put('N', Color.parseColor("#9E9E9E"));
    return hashMap;
}

From source file:Main.java

public static List<String> getPackage(Context context) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    Gson gson = new Gson();
    String json = sharedPrefs.getString(APP_LIST, null);
    Type type = new TypeToken<ArrayList<String>>() {
    }.getType();/*from w w w.j a  va 2 s  .  c  o m*/
    return gson.fromJson(json, type);
}

From source file:Main.java

public static void prepareHPCCData(Context context) {
    if (HPCCSTATS_USER == "" || getHPCCPage() == "") {
        SharedPreferences prefs = context.getSharedPreferences("org.linuxguy.HPCCMonWidget", 0);
        HPCCSTATS_USER = prefs.getString("hpccmonwidget_user", "");
        setHPCCPage(prefs.getString("hpccmonwidget_url", ""));
        Log.i("Status", "prepareHPCCData()");
    }/*from   w w  w. ja  v a  2 s .co  m*/
}

From source file:Main.java

public static String getPlusImageUrl(final Context context) {
    SharedPreferences sp = getSharedPreferences(context);
    return hasActiveAccount(context)
            ? sp.getString(makeAccountSpecificPrefKey(context, PREFIX_PREF_PLUS_IMAGE_URL), null)
            : null;/*from   www. jav  a 2  s.c  o m*/
}

From source file:Main.java

public static String getAvatarNormal(final Context context) {
    SharedPreferences sp = getSharedPreferences(context);
    return hasActiveAccount(context)
            ? sp.getString(makeAccountSpecificPrefKey(context, PREFIX_PREF_AVATAR_NORMAL), null)
            : null;//from  w w w . j  a v  a  2s. com
}

From source file:Main.java

public static String getAvatarMini(final Context context) {
    SharedPreferences sp = getSharedPreferences(context);
    return hasActiveAccount(context)
            ? sp.getString(makeAccountSpecificPrefKey(context, PREFIX_PREF_AVATAR_MINI), null)
            : null;//from www. ja  v a  2 s  .  c o  m
}

From source file:Main.java

public static String getAvatarLarge(final Context context) {
    SharedPreferences sp = getSharedPreferences(context);
    return hasActiveAccount(context)
            ? sp.getString(makeAccountSpecificPrefKey(context, PREFIX_PREF_AVATAR_LARGE), null)
            : null;//  w  w w.ja v  a 2s .c  om
}

From source file:Main.java

public static boolean hasToken(final Context context, final String accountName) {
    SharedPreferences sp = getSharedPreferences(context);
    return !TextUtils
            .isEmpty(sp.getString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_AUTH_TOKEN), null));
}

From source file:Main.java

public static boolean hasPlusInfo(final Context context, final String accountName) {
    SharedPreferences sp = getSharedPreferences(context);
    return !TextUtils
            .isEmpty(sp.getString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_PLUS_PROFILE_ID), null));
}

From source file:Main.java

private static String generateKeevaId(Context context) {
    SharedPreferences sharedPrefs = context.getSharedPreferences("store.kv.db", Context.MODE_PRIVATE);
    String generatedId = sharedPrefs.getString(DB_KEY_SOOMLA_GENERATED_ID, null);
    if (TextUtils.isEmpty(generatedId)) {
        generatedId = UUID.randomUUID().toString();
        sharedPrefs.edit().putString(DB_KEY_SOOMLA_GENERATED_ID, generatedId).commit();
    }/*w ww . j a v a2  s .co m*/
    return generatedId;
}