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 getUserPwd(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE);
    String userPwd = preferences.getString(USER_PWD, "");
    return userPwd;
}

From source file:Main.java

public static String ReadSharedPreferencesString(Context context, String name, String key,
        String defaultvalue) {//from  w  ww.  ja v a 2s . com
    try {
        SharedPreferences userInfo = context.getSharedPreferences(name, Context.MODE_WORLD_READABLE);
        return userInfo.getString(key, defaultvalue);
    } catch (NullPointerException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

/**
 * @Title: getSettingRingtone/*from  w ww. ja  v  a  2s .  c o m*/
 * @Description: Get current setting ring tone
 * @param context
 * @param type
 * @return
 * @return String
 * @throws
 */
public static String getSettingRingtone(Context context, int type) {
    SharedPreferences mSharePref = PreferenceManager.getDefaultSharedPreferences(context);
    String value = mSharePref.getString(TYPE_PRE + type, "");
    return value;
}

From source file:Main.java

public static String LoadAccountPwd(Context ctx) {
    String password = "";

    try {//from  w ww.j av a 2 s .  co  m
        SharedPreferences savePref = ctx.getSharedPreferences(g_sUserPref, ctx.MODE_PRIVATE);
        password = savePref.getString("Password", "");
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return password;
}

From source file:Main.java

public static String getUserIcon(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE);
    String userIcon = preferences.getString(USER_ICON, "");
    return userIcon;
}

From source file:Main.java

public static String getUserId(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE);
    String userIcon = preferences.getString(USER_ID, "");
    return userIcon;
}

From source file:Main.java

public static String getUserName(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE);
    String userIcon = preferences.getString(USER_NAME, "");
    return userIcon;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

    if (prefs.getString(PREFS_KEY_PASSCODE, null) != null)
        return true;
    else//from ww w .ja  va2s  .c  o m
        return false;
}