From time to time, we need to persist some values. Typical examples are a high score or the settings of our game. AndEngine doesn't have any built-in mechanism for this, but we can use the Android SDK to achieve it.
There are two ways. A simple way is to use shared preferences, which is a key-value persistent storage. A more robust but more complicated way is to use the SQLite database, which is accessible from every Android application. We are going to use the simple way to store the high score and sound settings.
Each application has access to its
Preferences object. It's basically a key-value map. It is very simple to use preferences, but it's easy to make a mistake. First, we need to initialize the storage. This ...