O'Reilly logo

Android Game Programming For Dummies by Derek James

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10

Storing and Retrieving Game Information

In This Chapter

arrow Using Android’s SharedPreferences file

arrow Reading and writing XML

arrow 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

check.png Options (such as sound/music settings)

check.png High scores

check.png 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required