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 long getLongCache(Context context, String key) {
    if (sp == null) {
        sp = context.getSharedPreferences(CACHE_FILE_NAME, Context.MODE_PRIVATE);
    }/*from   w w w  .  j  a  v  a2s  .com*/
    return sp.getLong(key, 0);
}

From source file:Main.java

public static String getLAT(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(LAT, Context.MODE_PRIVATE);
    String city = preferences.getString(CVALUE, "40.017349");
    return city;/*  w  w w.  ja  v a2  s  . c  o m*/
}

From source file:Main.java

public static String getLNG(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(LNG, Context.MODE_PRIVATE);
    String city = preferences.getString(CVALUE, "116.40712");
    return city;//from   w  w  w .j  ava 2  s  .  c om
}

From source file:Main.java

public static boolean getVersionCode(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(VERSION_S, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(VERSION_S_K, false);
}

From source file:Main.java

public static int getIntFromSharePrefs(Context context, String fileName, String key, int defaultValue) {
    if (context == null) {
        return defaultValue;
    }//from  w  ww .j a  va2s .c  om
    SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preferences.getInt(key, defaultValue);
}

From source file:Main.java

public static String readString(Context context, String key) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    return pre.getString(STORE_KEY_PREFIX + key, "");
}

From source file:Main.java

public static void setUIScrollableWidgets(Context context, boolean value) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putBoolean("uiScrollableWidgets", value);
    editor.commit();/*from w  w w .  jav  a  2 s .co  m*/
}

From source file:Main.java

public static <T> void writeSerializedObject(Context context, String fileName, T objectToWrite)
        throws IOException {
    FileOutputStream fileOut = context.openFileOutput(fileName, Context.MODE_PRIVATE);
    ObjectOutputStream out = new ObjectOutputStream(fileOut);
    out.writeObject(objectToWrite);/*from www .  ja  v  a 2 s  .  c  o m*/
    out.close();
    fileOut.close();
}

From source file:Main.java

public static void setThemePackageName(Context context, String packageName) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("themePackageName", packageName);
    editor.commit();// ww  w. j a  v  a  2  s .  c o  m
}

From source file:Main.java

public static void putStrogeB(Context context, boolean value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(StrogeB, Context.MODE_PRIVATE);
    SharedPreferences.Editor edit = sharedPreferences.edit();
    edit.putBoolean(StrogeB_K, value);/*from w  w w . ja v a  2s.  c  o m*/
    edit.commit();
}