¿Es posible almacenar un objeto Date
usando SharedPreferences
?¿Cómo almacenar un objeto Date en SharedPreferences?
Actualmente en mi código tengo una variable String
, boolean
y Date
. Aquí está mi función para almacenar todos los objetos excepto Date
. Entonces, ¿cómo se puede hacer eso por favor sugiérame?
private void SavePreferences() {
String key="1";
String value="hello";
int x=5;
Date currentDate=new Date();
SharedPreferences sharedPreferences = getPreferences(MODE_APPEND);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, value);
editor.putInt("2",5);
editor.commit();
}
Así que mi pregunta es cómo almacenar la Date
usando SharedPreferences
?
vez Almacené data..and nuevamente abrir la aplicación .. tengo un botón de reinicio ... una vez que hago clic en el botón de reinicio es posible eliminar todos estos datos almacenados ... que he almacenado usando shredPreferences. – AndroidDev
'editor.clear(). Commit();' –
Respuesta simple, excelente. –