Valores predeterminados de Android para las preferencias compartidas
Estoy tratando de entender las SharedPreferences de Android. Soy un principiante y no sé mucho al respecto.
Tengo esta clase implementada para mi aplicación Preferencias
public class Preferences {
public static final String MY_PREF = "MyPreferences";
private SharedPreferences sharedPreferences;
private Editor editor;
public Preferences(Context context) {
this.sharedPreferences = context.getSharedPreferences(MY_PREF, 0);
this.editor = this.sharedPreferences.edit();
}
public void set(String key, String value) {
this.editor.putString(key, value);
this.editor.commit();
}
public String get(String key) {
return this.sharedPreferences.getString(key, null);
}
public void clear(String key) {
this.editor.remove(key);
this.editor.commit();
}
public void clear() {
this.editor.clear();
this.editor.commit();
}
}
La cosa es que me gustaría establecer preferencias por defecto. Se establecerán cuando la aplicación esté instalada y luego la aplicación podrá modificarla y permanecer persistente. Escuché sobre un preferences.xml pero no entiendo el proceso.
¿Alguien podría ayudarme?
Gracias por tu tiempo