smilevchy
5/23/2015 - 1:51 PM

SharedPreferencesManager

public class SharedPreferencesManager {
	private static final String XXX_SHARED_PREFS = "XXXSharedPrefs";

	private static SharedPreferences sharedPrefs = null;
	
	
	public static void init(Context ctx) {
		if (null == sharedPrefs) {
			sharedPrefs = ctx.getSharedPreferences(XXX_SHARED_PREFS, Context.MODE_PRIVATE);
			ResourceConfig.WORK_DISPLAY_TYPE = getString(SharedPreferencesKey.XXX, Pager.Mode.LIST);
		}
	}
	
	public static String getString(String key, String defValue) {
		return sharedPrefs.getString(key, defValue);
	}
	
	public static boolean putString(String key, String value) {
		Editor editor = sharedPrefs.edit();
		editor.putString(key, value);
		return editor.commit();
	}
	
	public static final class SharedPreferencesKey {
		public static final String XXX = "XXX";
	}
}