Reputation: 1180
I am trying to develop a little game in Libgdx/Java :) But before i implement a save system, i got some questions about it :
I often see, no i always see that games stores there game variables in files. And i already know how to save my data into an xml file ... which looks so :
<?xml version="1.0" encoding="UTF-8"?>
<Word>Hello</Word>
But is that efficient ? Or are there better methods to save data in files ? And is it worth to store data in files? An other little question is, how do i load that stuff out of this file above there? And example, if i wanna load the Word "Hello" into an String ... how do i do that?
I found some interesting posts but they didn't work, maybe they are outdated :/
Heres one : Java: How to read and write xml files?
Upvotes: 0
Views: 451
Reputation: 40
You could use Preferences:
Preferences prefs = Gdx.app.getPreferences("My Preferences");
prefs.putString("name", "Donald Duck");
String name = prefs.getString("name", "No name stored");
prefs.putBoolean("soundOn", true);
prefs.putInteger("highscore", 10);
Found it here: https://github.com/libgdx/libgdx/wiki/Preferences
Upvotes: 0