I am trying to save a highscore in APDE. I am currently trying to create the file
File highscoreData= new File("//storage/emulated/0/JGameData","highscore.txt");
if (highscoreData.exists()){
highscore=0;
highscoreArray = loadStrings("//storage/emulated/0/JGameData/highscore.txt");
highscore=float(highscoreArray[0]);
}
else {
highscoreData.mkdir();
highscoreData.createNewFile();
}
}
but I just get an unhandled IOException Error. What am I doing wrong?
@Janvonfalken ====
i dont use APDE but i think that in this case you can easily avoid this error coding like that:
File highscoreData= new File("//storage/emulated/0/JGameData","highscore.txt");
if (highscoreData.exists()){
highscore=0;
highscoreArray = loadStrings("//storage/emulated/0/JGameData/highscore.txt");
highscore = float(highscoreArray[0]);
}
else {
highscoreData.mkdir();
try {
highscoreData.createNewFile();
}catch(IOException e){
println(e);
}
}
Thanks for the answer, I tried a catch block but it didnt seem to work, it just didnt throw an error. Doesnt matter though, I solved the peoblem with Shared Preferences.
@Janvonfalken ===
In this type of case SharedPreferences is the STANDARD simple && good solution!