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 putFontSize(Context context, String key, int state) {
    SharedPreferences prefe = context.getSharedPreferences(PREFERNCE_FILE_NAME, Context.MODE_PRIVATE);
    Editor editor = prefe.edit();//w w  w .j av a  2 s  .c  o  m
    editor.putInt(key, state);
    editor.commit();
}

From source file:Main.java

public static String getDataFromSharedPreferences(Context context, String key) {
    SharedPreferences settings;/*from   w ww .  j  a va2  s .c o  m*/
    String value;
    settings = context.getSharedPreferences(FLICKR_PREFS, Context.MODE_PRIVATE);
    value = settings.getString(key, null);

    return value;
}

From source file:Main.java

public static void storeString(Context context, String key, String value) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    pre.edit().putString(STORE_KEY_PREFIX + key, value).commit();
}

From source file:Main.java

public static void setSharePref(Context context, String key, int value, int mode) {
    SharedPreferences sharedPref = context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);

    SharedPreferences.Editor editor = sharedPref.edit();

    editor.putInt(key, value);//  w w w .  ja  v  a2 s.  c  om

    editor.commit();
}

From source file:Main.java

public static void setLongPref(Context context, String name, long value) {
    SharedPreferences prefs = context.getSharedPreferences(APPLICATION_NAME, Context.MODE_PRIVATE);
    Editor ed = prefs.edit();//from   w  w w .j  a v  a2  s . com
    ed.putLong(name, value);
    ed.commit();
}

From source file:Main.java

public static void putCity(Context context, String city) {
    SharedPreferences preferences = context.getSharedPreferences(CITY, Context.MODE_PRIVATE);
    preferences.edit().putString(CVALUE, city).commit();
}

From source file:Main.java

public static boolean saveObject(Context context, Object data, String filename) {
    FileOutputStream out;/*from   w w  w .  ja  v a  2s  .  c o  m*/
    ObjectOutputStream oout;
    try {
        out = context.openFileOutput(filename + ".odb", Context.MODE_PRIVATE);
        oout = new ObjectOutputStream(out);
        oout.writeObject(data);
        oout.flush();
        out.flush();
        oout.close();
        out.close();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static boolean getCleanTagsBoolean(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(CleanTagsBoolean, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(CleanTagsBoolean_K, false);
}

From source file:Main.java

public static String get(Context context, String key, String defValue) {
    SharedPreferences preferences = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
    return preferences.getString(key, defValue);
}

From source file:Main.java

private static SharedPreferences getSp(Context context) {
    if (mPreferences == null) {
        mPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    }// w w w . j a  v  a  2 s.com

    return mPreferences;
}