public BackupInfo(final File f) throws JSONException, ParseException { final JSONObject obj = fromJSON(f); if (obj == null) { throw new JSONException("Backup file cannot be loadedd"); } this.type = EnumUtils.getByName(Type.class, obj.getString("type"), Type.USER); this.name = obj.getString("name"); this.timestamp = SDF.parse(obj.getString("timestamp")); }
@Override public void restore(final JSONObject root, final Editor edit) { final String value = root.optString(key); setPreferenceValue(edit, EnumUtils.getByName(enumClass, value, defValue)); }
public E getPreferenceValue(final SharedPreferences prefs, final E defValue) { if (!prefs.contains(key)) { prefs.edit().putString(key, defValue.getResValue()).commit(); } return EnumUtils.getByResValue(enumClass, prefs.getString(key, null), defValue); }
public EnumPreferenceDefinition(final Class<E> enumClass, final int keyRes, final int defValRef) { super(keyRes); this.enumClass = enumClass; this.defValue = EnumUtils.getByResValue(enumClass, BaseDroidApp.context.getString(defValRef), null); }