List of usage examples for android.content Context MODE_PRIVATE
int MODE_PRIVATE
To view the source code for android.content Context MODE_PRIVATE.
Click Source Link
From source file:Main.java
public static SharedPreferences getCommonSharedPref(Context context) { return context.getSharedPreferences(SHARED_PREFERENCES_COMMON, Context.MODE_PRIVATE); }
From source file:Main.java
@SuppressLint("CommitPrefEdits") public static void resetAll(String fileName, Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.clear();// w w w . j a va2 s .com editor.commit(); }
From source file:Main.java
public static Object get(Context context, String key, Object defaultObject) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); if (defaultObject instanceof String) { return sp.getString(key, (String) defaultObject); } else if (defaultObject instanceof Integer) { return sp.getInt(key, (Integer) defaultObject); } else if (defaultObject instanceof Boolean) { return sp.getBoolean(key, (Boolean) defaultObject); } else if (defaultObject instanceof Float) { return sp.getFloat(key, (Float) defaultObject); } else if (defaultObject instanceof Long) { return sp.getLong(key, (Long) defaultObject); }//from www. j a v a 2 s. c o m return null; }
From source file:Main.java
public static void saveLongToSharePrefs(Context context, String fileName, String key, long value) { SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); Editor editor = preferences.edit();/*from w w w. ja v a 2 s . co m*/ editor.putLong(key, value); editor.commit(); }
From source file:Main.java
public static void changeRingtone(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences("randomizer", Context.MODE_PRIVATE); if (!sharedPreferences.getBoolean("active", false)) { return;/*from ww w. j av a 2s. co m*/ } // END if RingtoneManager ringtoneManager = new RingtoneManager(context); Random random = new Random(System.currentTimeMillis()); int count = random.nextInt(ringtoneManager.getCursor().getCount()); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, ringtoneManager.getRingtoneUri(count)); }
From source file:Main.java
private static void saveSessionid(Context context, String sessionid) { SharedPreferences.Editor localEditor = context.getSharedPreferences(XL_PREFERENCES, Context.MODE_PRIVATE) .edit();//w w w.j a va 2 s . c o m localEditor.putString("sessionid", sessionid); localEditor.commit(); }
From source file:Main.java
public static boolean isPasscodeSet(Context context) { SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); if (prefs.getString(PREFS_KEY_PASSCODE, null) != null) return true; else/*w w w .jav a2 s . c om*/ return false; }
From source file:Main.java
public static void CacheString(String data, String filename, Context ctx) { try {//ww w. j a v a2s . c o m FileOutputStream fos = ctx.openFileOutput(filename, Context.MODE_PRIVATE); fos.write(data.getBytes()); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static String getHomeData(Context context, String key, String default_value) { SharedPreferences sharedPreferences = context.getSharedPreferences(HOME_DATA, Context.MODE_PRIVATE); return sharedPreferences.getString(key, default_value) == null ? "" : sharedPreferences.getString(key, default_value); }
From source file:Main.java
public static String getString(Context context, String key, String defValue) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); return sp.getString(key, defValue); }