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 isBind(Context context) {
    SharedPreferences sp = context.getSharedPreferences("pre_tuisong", Context.MODE_PRIVATE);
    return sp.getBoolean(BIND__FLAG, false);
}

From source file:Main.java

public final static void removeUserPreferences(Activity context) {
    SharedPreferences sharedPref = context.getSharedPreferences("currentUser", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.clear();/*from w  ww.  ja  va 2  s  . co  m*/
    editor.commit();
}

From source file:Main.java

public static void putValue(Context context, String value) {
    SharedPreferences spf = context.getSharedPreferences("md5", Context.MODE_PRIVATE);
    Editor edit = spf.edit();//from ww w . ja v  a  2  s  .  co  m
    edit.putString("sha", value);
    edit.commit();
}

From source file:Main.java

public static void clean(Context cxt, String fileName) {
    SharedPreferences preference = cxt.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    Editor editor = preference.edit();/*from   w  ww.  j a  v a2s. c o m*/
    editor.clear();
    editor.commit();
}

From source file:Main.java

public static int loadActivityStatus(Context context) {
    SharedPreferences pref = context.getSharedPreferences("ActivityStatus", Context.MODE_PRIVATE);
    return pref.getInt("activity_status", ERROR_STATUS);
}

From source file:Main.java

public static int getInt(Context context, String key) {
    if (sp == null) {
        sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    }//from   w ww. j a  va2  s . c  om
    return sp.getInt(key, 0);
}

From source file:Main.java

public static Adapter readUser(Context con) {
    Adapter at = null;//from w w w.jav a2 s.com
    SharedPreferences sp = con.getSharedPreferences("acToken", Context.MODE_PRIVATE);
    String key = sp.getString("key", null);
    String secret = sp.getString("secret", null);
    if (key != null) {
        // at=new AccessToken(key,secret);

    }
    return at;
}

From source file:Main.java

public static void setInt(Context ctx, String key, int value) {
    SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    sp.edit().putInt(key, value).commit();
}

From source file:Main.java

public static String readPrefernce(Context context, String fileName, String key, String defaultValue) {
    SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preferences.getString(key, defaultValue);

}

From source file:Main.java

public static Boolean getBoolean(Context context, String key) {
    sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
    return sp.getBoolean(key, false);
}