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 String getString(Context context, String key) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("fucang", Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, "");
}

From source file:Main.java

public static String getUserID(Context mContext) {
    SharedPreferences sharedPref = mContext.getSharedPreferences("IdentifyInfos", Context.MODE_PRIVATE);
    return sharedPref.getString("sess_userid", "0");
}

From source file:Main.java

public static String getString(String fileName, Context context, String keyId, String defaultValue) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return sharedPreferences.getString(keyId, defaultValue);
}

From source file:Main.java

public static String getUserMail(Context mContext) {
    SharedPreferences sharedPref = mContext.getSharedPreferences("IdentifyInfos", Context.MODE_PRIVATE);
    return sharedPref.getString("user_mail", "");
}

From source file:Main.java

public static String getLogin(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getString(PREF_SAVED_LOGIN, null);
}

From source file:Main.java

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

From source file:Main.java

public static String getZfbType(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(ZfbType, Context.MODE_PRIVATE);
    return sharedPreferences.getString(ZfbType_K, "");
}

From source file:Main.java

public static String getFromPref(Context context, String key, String defVal) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(FILENAME, context.MODE_PRIVATE);
    return sharedPreferences.getString(key, defVal);
}

From source file:Main.java

public static String getSharedPreferences(Context context, String key) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return sharedPreferences.getString(HORSEPUSH + key, "");
}

From source file:Main.java

public static <T> T getObject(String preName, Context context, String key, Class<T> clazz) {
    SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
    String str = pre.getString(key, "");
    return TextUtils.isEmpty(str) ? null : new Gson().fromJson(str, clazz);
}