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 void cacheFlyDuration(Context context, long time) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
    sp.edit().putLong(KEY_BD, time).commit();
}

From source file:Main.java

public static String getUserName(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USER_INFO, Context.MODE_PRIVATE);
    String userIcon = preferences.getString(USER_NAME, "");
    return userIcon;
}

From source file:Main.java

public static void putString(Context context, String key, String Value) {
    if (sharedPreferences == null) {
        sharedPreferences = context.getSharedPreferences("Cache", Context.MODE_PRIVATE);
    }//ww  w  . ja  v a2  s .c  om
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(key, Value);
    editor.commit();
}

From source file:Main.java

public static String getSystemValue(String key, Context p_context) {
    String value = null;/*www .j  av a  2s  . co  m*/
    SharedPreferences myPrefs = p_context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    value = myPrefs.getString(key, null);

    return value;
}

From source file:Main.java

public static boolean getBooleanPreferences(Context context, String name) {
    try {//from ww  w .j  av a 2 s.c o  m
        return context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).getBoolean(name,
                false);
    } catch (Exception e) {
        Log.e("datautils", e.getMessage());
        remove(context, name);
    }
    return false;
}

From source file:Main.java

public static SharedPreferences getSharedPref(Context c) {
    return c.getSharedPreferences(c.getPackageName(), Context.MODE_PRIVATE);
}

From source file:Main.java

public static void editDeviceId(Context context, String deviceId) {
    SharedPreferences preferences = context.getSharedPreferences(DEVICE, Context.MODE_PRIVATE);
    preferences.edit().putString(DEVICEID, deviceId).commit();
}

From source file:Main.java

public static void putLiveType(Context context, String type) {
    SharedPreferences preferences = context.getSharedPreferences(LIVE_TYPE, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, type).commit();
}

From source file:Main.java

public static void setParam(Context context, String key, Object object) {

    String type = object.getClass().getSimpleName();
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();

    if ("String".equals(type)) {
        editor.putString(key, (String) object);
    } else if ("Integer".equals(type)) {
        editor.putInt(key, (Integer) object);
    } else if ("Boolean".equals(type)) {
        editor.putBoolean(key, (Boolean) object);
    } else if ("Float".equals(type)) {
        editor.putFloat(key, (Float) object);
    } else if ("Long".equals(type)) {
        editor.putLong(key, (Long) object);
    }//from   w ww  .  ja v  a  2 s . c  o m

    editor.commit();
}

From source file:Main.java

public static boolean getPermissionBoolean(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(PermissionBoolean, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(PermissionBoolean_K, false);
}