I'm creating the specification for a game I'm about to 开发者_如何学Gostart creating on android, my main concern is how should I keep scores and settings on android? I assume they would be two different things.
The game has players that will have their settings and scores stored and then a settings menu (for the person setting up the game, not necessarily the player).
How would I go about storing these things? What type of data storage means should I be looking into?
Settngs of your game should be stored in SharedPreferences, also you can use default preferences to set some default setting, just use
PreferenceManager.setDefaultValues(context, R.xml.preferences, readAgain);
What about scores I think you sould store it into SQLite database. In future if you plan you can export scores, sync with server etc. If you will use preferences for storing scores it could be more difficult.
By the sounds of it I would be looking into using a SQLite database, that is if you want to save settings for each user along with a score.
If there are very few settings and it is only a simple int score, you could use SharedPreferences like mentioned, but if you want to start storing more data for each user, it will get confusing quickly, as they are really quite a simple data store.
For the general application settings the SharedPreferences should be what you'Re looking for for the scores ... well it depends on what kind of data that is. It is is really just a score (integer) then you can of course save it in the SharedPreferences too.
精彩评论