Search code examples
androidstate-saving

How to save settings of the game?


I'm developing simple android game with a menu and 3 stages of game. Currently I'm working on saving game state. In the menu activity user can change some settings such as audio(on/off), ads(on/off), etc. When the user presses "new game", therefore leaves menu activity for game activity:

1) Should I finish menu activity and restart it by intent every time user presses back button in the game? Keeping them both(menu activity and the game activity) alive gives OutOfMemory error.

2) Where I should save settings user changed in the menu?

Saving game state and android development is new to me, so I would appreciate detailed replies.


Solution

  • Your data storage options are the following:

    1. Shared Preferences : Store private primitive data in key-value pairs.
    2. Internal Storage : Store private data on the device memory.
    3. External Storage : Store public data on the shared external storage.
    4. SQLite Databases : Store structured data in a private database.
    5. Network Connection : Store data on the web with your own network server.

    source : developer.android.com