1
\$\begingroup\$

I am nearly finished with my Android game, but I want to make sure my save format is good. I am working on a fairly large game, so data such as high scores, stars, etc. are stored for around 80 levels, along with data for purchased items. Currently I save this data sequentially in a binary file. So when I need to load it, I have to go through all of the previous data to get to the data that I actually need. It seems to work fine, but I question how well this format will hold up for game updates. Is this is a bad approach to take? I considered using SQLite, but after trying to implement it into my game it didn't seem very effective. Updates seem as if they would be even more complicated.

\$\endgroup\$
0
\$\begingroup\$

How much is all your data? If all your achievements and stars fit within 1 MB, you'll be pretty much safe to save all this in one binary blob.

I would avoid easily-readable formats like XML, because this allows your players to read and edit anything they like, like getting through levels and get the stars they don't deserve.

Something like binary format, compressed with zip if you care about the size and encrypted if you care about the security would work just perfectly.

\$\endgroup\$
  • \$\begingroup\$ After more research, I decided that I am just going to stick with the binary files. My data is definitely less than 1 MB, so I think that it will be fine. \$\endgroup\$ – Dust1n May 20 '14 at 5:23
1
\$\begingroup\$

A human-readable format like XML would likely make debugging the data easier. However, binary data is generally much faster. It really depends on how often you are reading and writing the data, and how much data you are loading and saving.

If you have a small amount of data, you should just consider keeping all of the data in memory while the game is running and only reading from the file when the app is started.

\$\endgroup\$
  • \$\begingroup\$ Currently I only do one load, which is at the start of the application. Game saves are done only after level completion or if the player purchases an item. \$\endgroup\$ – Dust1n May 19 '14 at 16:57
  • \$\begingroup\$ In that case, it sounds like speed is not a #1 priority. I would recommend XML. I'm not sure about Java, but C# has awesome XML serialization that is soooo easy to use! You can turn your objects into xml with very little effort. \$\endgroup\$ – LVBen May 19 '14 at 17:05
  • \$\begingroup\$ android has no C# support. \$\endgroup\$ – lenik May 19 '14 at 17:18
  • \$\begingroup\$ I'd assume that Java has something similar, but like I said, I don't know for sure. \$\endgroup\$ – LVBen May 19 '14 at 17:18
  • 1
    \$\begingroup\$ nobody uses XML in java, except when writing legacy applications. most people use JSON nowadays, it's compact, easy to read and understand and has a nice support in Android. \$\endgroup\$ – lenik May 19 '14 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.