0

I'm working with AndEngine to create a simple 2D game. I plan to save the game state in a JSON object in the onPauseGame() method provided by the framework and reloading from the JSON in onResumeGame(). I'm not sure how I should save the JSON object though. Should I keep it in the sqlite DB or should I just use a regular file?

Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188

1 Answers1

0

I would suggest that you go with a File based approach to keep things simple. Alternately, you could also look at SharedPreferences to save the data. The latter approach is much simpler with a cleaner API.

Romin
  • 8,708
  • 2
  • 24
  • 28
  • How big a string can `SharedPreferences` hold? The game is a tower defense and every tower, enemy, projectile, etc. will be in this JSON so it might get large. – Corey Ogburn Nov 27 '12 at 03:06
  • SharedPreferences are written into an XML file behind the scenes. So as such there would not be any specific limits for the file. However, within a particular SharedPreferences file, you might have several values and one of them is your game state. It seems that this might be limited currently to 8192 characters. http://developer.android.com/reference/java/util/prefs/Preferences.html#MAX_VALUE_LENGTH . Some additional references can be found here: http://stackoverflow.com/questions/4925194/whats-the-maximum-size-for-an-android-shared-preference-value?lq=1 – Romin Nov 27 '12 at 03:11