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

public static boolean isLawyer(SharedPreferences user_sp) {
    if (TextUtils.isEmpty(user_sp.getString("lawyerid", ""))) {
        return false;
    }/*w  w  w .j  a  v a2 s.  c o  m*/
    return true;
}

From source file:Main.java

public static boolean isUser(SharedPreferences user_sp) {
    if (TextUtils.isEmpty(user_sp.getString("userid", ""))) {
        return false;
    }//w w w  .j  a  v a 2 s.  com
    return true;
}

From source file:Main.java

private static String getStringFromPrefsOrThow(SharedPreferences prefs, String key) {
    String val = prefs.getString(key, null);
    if (val == null) {
        throw new NullPointerException("Trying to retrieve pin value before it's been set");
    }/*from  w w w  .j  a va2s.  c  o  m*/
    return val;
}

From source file:Main.java

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

From source file:Main.java

public static String getPrefrence(SharedPreferences pref, String key) {
    try {/*  ww  w . j  a v  a  2s.  co  m*/
        return pref.getString(key, "");
    } catch (Exception ex) {
        return "";
    }
}

From source file:Main.java

public static String getSharedPreferences(Context ctx, String groupkey, String key) {
    SharedPreferences pref = ctx.getSharedPreferences(groupkey, 0);
    return pref.getString(key, "");
}

From source file:Main.java

@Nullable
private static String getString(Context context, String key) {
    SharedPreferences sp = getSharedPreferences(context);
    return sp.getString(key, null);
}

From source file:Main.java

public static String getStrValue(Context context, String name, String defValue) {
    SharedPreferences pref = getPref(context, DEF_PREF_NAME);
    return pref.getString(name, defValue);
}

From source file:Main.java

public static String read(Context context, String key, String defValue) {
    SharedPreferences sp = context.getSharedPreferences("app", 0);
    return sp.getString(key, defValue);
}

From source file:Main.java

public static String getString(Context context, String tag) {
    SharedPreferences prefs = getSharedPreference(context);
    return prefs.getString(tag, "");
}