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 deleteLoginInfo(Context context) {
    SharedPreferences.Editor editor = context.getSharedPreferences("LoginCookie", Context.MODE_PRIVATE).edit();
    editor.clear().commit();//from ww w.java2  s  .c  o m
}

From source file:Main.java

public static boolean HasSeenBefore(String name, Context context) {
    SharedPreferences sharedPrefs = context.getSharedPreferences(prefCategoryName, Activity.MODE_PRIVATE);
    return sharedPrefs.getBoolean(name, false);
}

From source file:Main.java

public static boolean getDesktopBlocked(Context context) {
    SharedPreferences sp = sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    ;//from   w  w  w  . j a v a 2  s. c  o  m
    boolean newD = sp.getBoolean("desktopBlocked", false);
    return newD;
}

From source file:Main.java

public static int getMode(String txt, Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(txt, Context.MODE_PRIVATE);
    return sp.getInt(key, -1);
}

From source file:Main.java

public static String getFaceUri(String faceId, Context context) {
    SharedPreferences faceIdUriMap = context.getSharedPreferences("FaceIdUriMap", Context.MODE_PRIVATE);
    return faceIdUriMap.getString(faceId, "");
}

From source file:Main.java

public static boolean getBoolean(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("xiaolu", Context.MODE_PRIVATE);
    return sp.getBoolean(key, false);
}

From source file:Main.java

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

From source file:Main.java

public static void deleteIp(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(IP_PORT, Context.MODE_PRIVATE);
    preferences.edit().clear().commit();
}

From source file:Main.java

public static int getMsgFirstSyncKey(String targetId, Context context) {
    SharedPreferences preferences = context.getSharedPreferences("messageFirstSync" + targetId,
            Context.MODE_PRIVATE);
    return preferences.getInt("targetId", 0);
}

From source file:Main.java

public static void setBoolean(Context context, String key, boolean value) {
    sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, value).commit();
}