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 SharedPreferences init(Context context) {
    if (sp == null) {
        sp = context.getSharedPreferences(PERF_NAME, Context.MODE_PRIVATE);
    }/*from w  w w . j  a va2 s .co m*/
    return sp;
}

From source file:Main.java

public static String getSharedPreString(Context context, String key) {
    settings = context.getSharedPreferences(XML_Settings, Context.MODE_PRIVATE);
    return settings.getString(key, "");
}

From source file:Main.java

public static boolean isInitialised(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
    return prefs.getBoolean(PREF_INITIALISED, false);
}

From source file:Main.java

public static void setInt(Context context, String key, int value) {
    if (sp == null) {
        if (context != null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }//w w w  .  j  ava 2  s.co m

    }
    sp.edit().putInt(key, value).commit();
}

From source file:Main.java

public static int getCurrentAppCatalog(Context context) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    int newD = sp.getInt("currentAppCatalog", -1);
    return newD;//from  w ww . j av  a  2 s .c  o  m
}

From source file:Main.java

public static boolean getCameraActive(Context context) {
    SharedPreferences sd = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    return sd.getBoolean(CAMERA_ACTIVE, false);
}

From source file:Main.java

public static void setMsgFirstSyncKey(String targetId, Context context) {
    SharedPreferences preferences = context.getSharedPreferences("messageFirstSync" + targetId,
            Context.MODE_PRIVATE);
    SharedPreferences.Editor editor1 = preferences.edit();
    editor1.putInt("targetId", 1);
    editor1.commit();/*from   w  w w . jav a2 s.  c  om*/
}

From source file:Main.java

public static void putString(Context context, String key, String value) {
    if (sp == null) {
        sp = context.getSharedPreferences(APP, Context.MODE_PRIVATE);
    }/*from w ww  .  j ava  2s.co  m*/
    sp.edit().putString(key, value).apply();
}

From source file:Main.java

public static Boolean getBoolean(Context mContext, String name, String key, Boolean defaultValue) {
    if (isExist(mContext, name, key)) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE);
        return sharedPreferences.getBoolean(key, defaultValue);
    } else {// w  ww.j a  va2  s  .  c om
        return false;
    }
}

From source file:Main.java

private static SharedPreferences getSharedPreferences(final Context context) {
    return context.getSharedPreferences(PREFERENCE_FILE_NAME, Context.MODE_PRIVATE);
}