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 void setShowIntroduce(Context context) {
    SharedPreferences sp = context.getSharedPreferences("alumni", Activity.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putBoolean("showintro", true);
    editor.commit();// w  ww.j  av a2 s .c  o m
}

From source file:Main.java

public static void logOut(Context context) {
    SharedPreferences pref = context.getSharedPreferences(context.getPackageName() + "_preferences", 0);
    pref.edit().putString(ACCESS_TOKEN, "").putString(EXPIRES_IN, "").putString(UID, "").commit();
}

From source file:Main.java

public static String getDeviceId(Context context) {
    SharedPreferences mPrefs = context.getSharedPreferences(DEVICE_ID_FILE, Context.MODE_PRIVATE);
    return mPrefs.getString(DEVICE_ID_KEY, null);
}

From source file:Main.java

public static void clearWLPref(Context context) {
    SharedPreferences prefs = context.getSharedPreferences("WLPrefs", 0);
    SharedPreferences.Editor editor = prefs.edit();
    editor.clear();/*from  w ww.  ja va 2 s  . com*/
    editor.commit();
}

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 getUserMail(Context mContext) {
    SharedPreferences sharedPref = mContext.getSharedPreferences("IdentifyInfos", Context.MODE_PRIVATE);
    return sharedPref.getString("user_mail", "");
}

From source file:Main.java

public static boolean havePortScreen(Context context) {
    SharedPreferences sp = context.getSharedPreferences("port_size", 0);
    if (sp.getInt("height", 0) != 0)
        return true;
    else {//from   ww w .  j  a  va 2s.  c  o  m
        return false;
    }
}

From source file:Main.java

public static boolean haveLandScreen(Context context) {
    SharedPreferences sp = context.getSharedPreferences("land_size", 0);
    if (sp.getInt("height", 0) != 0)
        return true;
    else {//from w  ww. jav a  2 s.c o m
        return false;
    }
}

From source file:Main.java

public static String getSalesId(Context context) {
    SharedPreferences pref = context.getSharedPreferences("sales", Context.MODE_PRIVATE);
    if (pref != null) {
        return pref.getString("SalesId", "");
    }//w w  w  . ja v a2s .  co m
    return null;
}

From source file:Main.java

public static void init(Context context, String prefName) {
    prefs = context.getSharedPreferences(prefName, Context.MODE_PRIVATE);
}