Hi,
I'm trying to save an integer array but seem to be having an issue just saving a variable. I used the following code based off this thread http://www.anddev.org/write_to_and_read ... t3173.html but it doesn't seem to want to save an integer. I'll finish my level get a high score than save it. But when I reload it, I get a weird number. For example I'll save 2000 but get back 38 when I load it. Sometimes it's 216. It seems really random. Here's my code.
public void WriteSettings(Context context, Integer highscore){
FileOutputStream out = null;
try{
out = openFileOutput("settings.dat",MODE_PRIVATE);
out.write(highscore);
Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show();
}
finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public int ReadSettings(Context context){
FileInputStream fIn = null;
try{
fIn = openFileInput("settings.dat");
highscorepull = fIn.read();
fIn.close();
Toast.makeText(context, "Settings read",Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();
}
finally {
try {
outin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return highscorepull;
}
Ultimately I want to save an array like highscore[0] = highest, highscore[1] = lowest, and so on.
Any ideas as to what classes I should use?
Thanks!

