I’m trying to save some data to A file in android, I’m using herefor the internal storage of the android system. I looked it up on the developers guide of android and I came to this.
String FILENAME = "LangFile";
String data ="NL";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(data.getBytes());
fos.close();
This is how I save it to the file.
String FILENAME = "LangFile";
String languege = "lang";
FileInputStream fos = openFileInput(FILENAME);
fos.read(languege.getBytes());
fos.close();
if(languege=="NL"){
newgame.setText(R.string.dutchgames);
stats.setText(R.string.duthstats);
}
This is how I read from the same file, but if I run it it just gives an empty button?
You can’t compare strings using
==, in fact you need to use eitherequalsorequalsIgnoreCasemethods. You also need to tweak your reading logic a little. Change your code as below: