Storing and Retrieving Game Information
In This Chapter
Reading and writing XML
Creating SQLite databases
Playing games on a mobile device comes with the inherent issue that the device is often used for other things — like phone calls — which means your game is more likely to be interrupted at some point than it would be on devices like PCs or consoles. Even when the game itself is not disrupted, there’s usually information that you would like to persist (store between sessions), even if the gaming sessions are bite-size.
Common examples of data you’d want to persist include
Options (such as sound/music settings)
The state of an individual game (where game elements were located; what the score was, and so on)
When it comes to storing and retrieving data, you have several options:
SharedPreferences (key-value pairs for ...