Example usage for android.content Context MODE_PRIVATE

List of usage examples for android.content Context MODE_PRIVATE

Introduction

In this page you can find the example usage for android.content Context MODE_PRIVATE.

Prototype

int MODE_PRIVATE

To view the source code for android.content Context MODE_PRIVATE.

Click Source Link

Document

File creation mode: the default mode, where the created file can only be accessed by the calling application (or all applications sharing the same user ID).

Usage

From source file:Main.java

public static String getPubMod(String contactID, Context context) {
    SharedPreferences prefs = context.getSharedPreferences(contactID, Context.MODE_PRIVATE);

    String pubMod = prefs.getString(PREF_PUBLIC_MOD, DEFAULT_PREF);

    return pubMod;
}

From source file:Main.java

public static void removeString(Context context, String key) {
    SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    Editor editor = shared.edit();/*from w w w.  j ava 2  s . co m*/
    editor.remove(key);
    editor.commit();
}

From source file:Main.java

public static boolean isUserLoggedIn(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(USER_LOGGED_IN, false);
}

From source file:Main.java

public static synchronized String getUserName(final Context context) {
    SharedPreferences pref = context.getSharedPreferences(KEY_STORAGE, Context.MODE_PRIVATE);
    return pref.getString(AUTH_NAME, null);
}

From source file:Main.java

public static String getPubExp(String contactID, Context context) {
    SharedPreferences prefs = context.getSharedPreferences(contactID, Context.MODE_PRIVATE);

    String pubExp = prefs.getString(PREF_PUBLIC_EXP, DEFAULT_PREF);

    return pubExp;
}

From source file:Main.java

public static boolean isLogged(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(SHERED_NAME, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(SHARED_KEY_IS_LOGGED, false);
}

From source file:Main.java

public static void saveObject(Context context, String fileName, Object obj) throws IOException {
    FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
    ObjectOutput out = null;/*from www  .j av a2 s.  c  om*/
    try {
        out = new ObjectOutputStream(fos);
        out.writeObject(obj);
        out.flush();
    } finally {
        out.close();
        fos.close();
    }

}

From source file:Main.java

public static void saveLogin(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(SHERED_NAME, Context.MODE_PRIVATE);
    sharedPreferences.edit().putBoolean(SHARED_KEY_IS_LOGGED, true).commit();

}

From source file:Main.java

public static void registerChangeListener(Context context,
        SharedPreferences.OnSharedPreferenceChangeListener listener) {
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    sp.registerOnSharedPreferenceChangeListener(listener);
}

From source file:Main.java

public static void putIsOpenFirst(Context context) {
    if (sharedPreferences == null) {
        sharedPreferences = context.getSharedPreferences("led", Context.MODE_PRIVATE);
    }//from w  ww. j a v a2  s . com
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putBoolean("led", false);
    editor.commit();
}