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.Editor getPrefsEditor(Context ctx, String prefsKey) {
    return ctx.getApplicationContext().getSharedPreferences(prefsKey, Context.MODE_PRIVATE).edit();
}

From source file:Main.java

public static void storeDistanceTravelled(Context context, int distance) {
    SharedPreferences sharedPref = context.getSharedPreferences("Distance", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putInt("distance", distance);
    editor.apply();//  w  w w .jav  a  2s  .c  om
}

From source file:Main.java

public static String getPref(Context context, String name, String defaultValue) {
    SharedPreferences pref = context.getSharedPreferences("TVGuide", Context.MODE_PRIVATE);
    return pref.getString(name, defaultValue);
}

From source file:Main.java

public static void saveFirstLogin(Context context, boolean IsFirst) {
    SharedPreferences preferences = context.getSharedPreferences("FirstLogin", Context.MODE_PRIVATE);
    SharedPreferences.Editor edit = preferences.edit();
    edit.putBoolean("Isfirst", IsFirst);
    edit.commit();/*from w  w  w. j  a  v a2  s.c o m*/
}

From source file:Main.java

static public void saveIntegerPreferences(Context context, String key, int value) {
    SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.putInt(key, value);//from   w w w  . j  a  v  a 2  s .co  m
    editor.commit();
}

From source file:Main.java

public static void save(String filename, String content, Context context) throws Exception {
    FileOutputStream outStream = context.openFileOutput(filename, Context.MODE_PRIVATE);
    outStream.write(content.getBytes());
    outStream.close();//from   w w w. j a  va2s  .c o  m
}

From source file:Main.java

public static void putPlaymode(Context context, String key, int value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("fucang", Context.MODE_PRIVATE);
    sharedPreferences.edit().putInt(key, value).commit();
}

From source file:Main.java

private static int[] readCache(Activity activity) {
    SharedPreferences config = activity.getSharedPreferences("config", Context.MODE_PRIVATE);
    return new int[] { config.getInt("height", 0), config.getInt("width", 0) };
}

From source file:Main.java

public static void writeConfig(Context context, String key, String val) {
    SharedPreferences share = context.getSharedPreferences("perference", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = share.edit();
    editor.putString(key, val);
    editor.commit();/*w w w  .ja  va 2s  . co m*/
}

From source file:Main.java

public static void putSharedPref(Context context, String name, Object object) {
    SharedPreferences prefs = context.getSharedPreferences("TheMovieDb", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(name, object.toString());
    editor.commit();//from   ww w.  ja v a  2s  .c  om
}