Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer
    
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. –  user46079 May 20 '14 at 5:23

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.

share|improve this answer
    
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. –  user46079 May 19 '14 at 16:57
    
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. –  LVBen May 19 '14 at 17:05
    
android has no C# support. –  lenik May 19 '14 at 17:18
    
I'd assume that Java has something similar, but like I said, I don't know for sure. –  LVBen May 19 '14 at 17:18
1  
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. –  lenik May 19 '14 at 17:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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