List of usage examples for android.content Context getSharedPreferences
public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);
From source file:Main.java
public static void putInt(Context context, String key, int value) { SharedPreferences sp = context.getSharedPreferences("zexu", Context.MODE_PRIVATE); sp.edit().putInt(key, value).commit(); }
From source file:Main.java
private static SharedPreferences getPreference(Context context) { if (mSp == null) { mSp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE); }/* w w w. j a va2s. c om*/ return mSp; }
From source file:Main.java
public static void removeString(Context context, String key) { SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); Editor editor = shared.edit();/*from w w w .ja va2 s . co m*/ editor.remove(key); editor.commit(); }
From source file:Main.java
public static void removePreferenceNoId(Context ctx, String param) { SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.remove(param);// w w w . j a va 2 s.co m editor.commit(); }
From source file:Main.java
public static Set<String> getStringSetProperty(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(DEFAULT_FILE_NAME, Context.MODE_PRIVATE); return sp.getStringSet(key, null); }
From source file:Main.java
public static void putMode(String txt, Context context, String key, int value) { SharedPreferences sp = context.getSharedPreferences(txt, Context.MODE_PRIVATE); sp.edit().putInt(key, value).commit(); }
From source file:Main.java
public static void clear(Context context) { SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); settings.edit().clear().commit();/*from ww w. j a v a2s. c o m*/ }
From source file:Main.java
public static int getSharedTokenId(Context context) { int i;/*from ww w. j av a 2s . c o m*/ try { i = context.getSharedPreferences(context.getPackageName(), 1).getInt("session_token_id", 0); } catch (Exception exception) { return 0; } return i; }
From source file:Main.java
public static void setIntToCache(Context context, String key, int value) { SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE); sp.edit().putInt(key, value).commit(); }
From source file:Main.java
public static void setUserFromPrefrence(Context context, String nickname) { SharedPreferences sh = context.getSharedPreferences("xmeet_prefrence", Context.MODE_PRIVATE); Editor dt = sh.edit();//from w w w .j av a 2s .c o m dt.putString("nickname", nickname); dt.commit(); }