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 long getLongPref(Context context, String name, long def) { SharedPreferences prefs = context.getSharedPreferences(APPLICATION_NAME, Context.MODE_PRIVATE); return prefs.getLong(name, def); }
From source file:Main.java
public static void setBoolean(Context context, String key, boolean value) { sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); sp.edit().putBoolean(key, value).commit(); }
From source file:Main.java
public static void logout(Context context) { SharedPreferences preferences = context.getSharedPreferences("MyPrefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear();/*from w w w .j a v a 2 s . c om*/ editor.commit(); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); manager.cancelAll(); }
From source file:Main.java
public static void setLong(Context mContext, String name, String key, long value) { SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.putLong(key, value);/* w w w. ja v a 2 s.c o m*/ editor.commit(); }
From source file:Main.java
public static void deleteIp(Context context) { SharedPreferences preferences = context.getSharedPreferences(IP_PORT, Context.MODE_PRIVATE); preferences.edit().clear().commit(); }
From source file:Main.java
public static void setStr(Context mContext, String name, String key, String value) { SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.putString(key, value);//from www.ja v a 2 s .com editor.commit(); }
From source file:Main.java
public static int loadListPosition(Context context, String settings) { SharedPreferences pSharedPref = context.getSharedPreferences(settings, Context.MODE_PRIVATE); if (pSharedPref != null) { return pSharedPref.getInt(positionKey, 0); } else/*from ww w.ja v a2 s . co m*/ return 0; }
From source file:Main.java
public static void saveLong(Context context, String key, long value) { Editor editor = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit(); editor.putLong(key, value);//from w ww . j a v a 2 s . c om editor.commit(); }
From source file:Main.java
public static void changeRingtone(Context context) { SharedPreferences preferences = context.getSharedPreferences("randomizer", Context.MODE_PRIVATE); if (!preferences.getBoolean("active", false)) return;//from w w w . j a va2 s. c o m RingtoneManager mgr = new RingtoneManager(context); Random random = new Random(System.currentTimeMillis()); int n = random.nextInt(mgr.getCursor().getCount()); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, mgr.getRingtoneUri(n)); }
From source file:Main.java
public static String loadStringSavedPreferences(String key, Context ctx) { SharedPreferences sp = ctx.getSharedPreferences(sharedPrefsFile, Context.MODE_PRIVATE); String name = sp.getString(key, ""); return name;/* w ww. j a v a 2 s . c om*/ }