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 String getUserKbi(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO_OTHER, Context.MODE_PRIVATE);
    String userLevel = preferences.getString(USER_KBI, "");
    return userLevel;
}

From source file:Main.java

/**
 * Pops the latest message from the messages and returns it.
 * //from www . ja  v  a  2 s. c om
 * @param context The application context.
 * @return The latest message.
 */
public static String popLastMessage(Context context) {
    SharedPreferences sp = context.getSharedPreferences("messages", Context.MODE_PRIVATE);
    String last = sp.getString("last", null);
    sp.edit().putString("last", null).commit();
    return last;
}

From source file:Main.java

public static String getIpPort(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(IP_PORT, Context.MODE_PRIVATE);
    String ip = preferences.getString(CVALUE, "121.41.112.232:9418");
    return ip;//  w w  w.  j a v  a 2s . c  o  m
}

From source file:Main.java

public static String getUserPic(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USERPIC, Context.MODE_PRIVATE);
    String city = preferences.getString(CVALUE, "null");
    return city;/*from   w ww  . ja v a 2 s  .c  o  m*/
}

From source file:Main.java

public static String getQQid(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(QQ, Context.MODE_PRIVATE);
    String QQid = preferences.getString(QQ_ID, "");
    return QQid;//from  w  w w.j  av a2s. c o m
}

From source file:Main.java

public static boolean isLight(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(APP_THEME_LIGHT, Context.MODE_PRIVATE);
    boolean isLight = preferences.getBoolean(APP_LIGHT_KEY, true);
    return isLight;
}

From source file:Main.java

public static String getUserScore(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO_OTHER, Context.MODE_PRIVATE);
    String userLevel = preferences.getString(USER_SCORE, "");
    return userLevel;
}

From source file:Main.java

public static String getUserLevel(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO_OTHER, Context.MODE_PRIVATE);
    String userLevel = preferences.getString(USER_LEVEL, "");
    return userLevel;
}

From source file:Main.java

public static String getLiveType(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(LIVE_TYPE, Context.MODE_PRIVATE);
    String type = preferences.getString(CVALUE, "0");
    return type;/*w w w.  ja va2s  .co  m*/
}

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;
}