0
我試圖讓我的遊戲將分數保存到一個文本文件中,我稍後想要讀取它。但是,我似乎無法讓我的分數實際存儲在文件中?將分數保存到文本文件未更新文件? Android Studio
此外,我最終希望能夠只存儲前10位的分數,因此如果它高於文件中的分數,則覆蓋分數?什麼是最好的方式去做這件事?
謝謝!
public void saveGame(Integer score){
try {
OutputStreamWriter osw = new OutputStreamWriter(getGame().getFileIO().writeFile("storetxt.txt"));
osw.write(score);
osw.close();
}
catch (IOException e){
Log.e("Exception", "Couldn't write to file: " + e.toString());
}
}