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 boolean isControllerEnabled(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);

    // By default, when first time used, status is enabled
    return prefs.getBoolean(PREFS_CONTROLLER_STATUS, true);

}

From source file:Main.java

public static void putBoolean(Context context, String key, boolean value) {
    if (sp == null) {
        sp = context.getSharedPreferences(APP, Context.MODE_PRIVATE);
    }/*  ww w. jav  a2  s.  c o m*/
    sp.edit().putBoolean(key, value).apply();
}

From source file:Main.java

public static void storeDistanceAndLocation(Context context, HashMap<String, String> params) {
    SharedPreferences sharedPref = context.getSharedPreferences("DistanceAndLocation", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    for (Map.Entry<String, String> entry : params.entrySet()) {
        editor.putString(entry.getKey(), entry.getValue());
    }//  w  ww .j  ava  2s  . c  o m
    editor.apply();
}

From source file:Main.java

public static boolean getPreferenceBoolean(Context context, String key, boolean defValue) {
    SharedPreferences prefs = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
    boolean value = prefs.getBoolean(key, defValue);
    return value;
}

From source file:Main.java

/**
 *
 * @param context//  www.  j  a  v  a2s . c o m
 * @param key
 * @param values
 */
public static void putString(Context context, String key, String values) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("7Yan", Context.MODE_PRIVATE);
    sharedPreferences.edit().putString(key, values).commit();
}

From source file:Main.java

public static String getZfbType(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(ZfbType, Context.MODE_PRIVATE);
    return sharedPreferences.getString(ZfbType_K, "");
}

From source file:Main.java

public static String getSwipeUpAppToLaunchName(Context context) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    return "";
}

From source file:Main.java

public static String getSwipeUpAppToLaunchName(Context context) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    return sp.getString("swipeUpAppToLaunchName", "");
}

From source file:Main.java

private static SharedPreferences getPreference(Context context) {
    if (mSp == null) {
        mSp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
    }//  ww  w.  ja va2s.  c o m
    return mSp;

}

From source file:Main.java

public static Integer getUsageNumber(Context context) {
    Integer value = 0;/* w  w w  .ja  va  2s  . c om*/

    try {
        SharedPreferences settings = context.getSharedPreferences("Settings", Context.MODE_PRIVATE);
        value = settings.getInt("usage_num", 0);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return value;
}