
Originariamente inviato da
BobArctor
infatti ho appena risolto leggendo e scrivendo su sd...

grazie!!!
è da (molto) poco che utlizzo l'sdk di android, e non conosco ancora le differenze con java utilizzato fin'ora.
utilizzare un db per memorizzare 2 stringhe mi sembra eccessivo, e le shared preferences devo ancora studiarle... ^^
volevo utilizzare un file in res/raw perchè sapevo come "acchiapparlo", non sapendo di non poterlo poi riscrivere.
grazie ancora!
Michele
Piuttosto di un file su sd, ti consiglio di usare shared preferences, sono comodissime!
Per scrivere:
codice:
private static final String savePath="path";
private SharedPreferences sharedPref;
private SharedPreferences.Editor editor;
public void putStringFromPreferences(String stringaDaInserire){
sharedPref = this.getSharedPreferences(TUACLASSE.savePath, Activity.MODE_WORLD_WRITEABLE);
editor=sharedPref.edit();
editor.putString("CHIAVESTRINGA", stringaDaInserire);
editor.commit();
}
Per leggere ancora più easy:
codice:
private static final String savePath="path";
public String readString(){
sharedPref = this.getSharedPreferences(TUACLASSE.savePath, Activity.MODE_WORLD_WRITEABLE);
return sharedPref.getString("CHIAVESTRINGA", "TestoDiDefault");
}
Spero ti sia utlie!