Libgdx,save Game Data... can i use .properties or should i use JSON?

Libgdx,save Game Data… can i use .properties or should i use JSON?
I plan to play the game in desktop/android.

IM just wondering if this : http://www.mkyong.com/java/java-properties-file-examples/

Will work under android

Java .properties is really only useful if you have a very simple game state (e.g. level #). If it’s anything more complex you want to save JSON is an option, but you could also simply just use an ObjectOutputStream which works just fine. Each of these methods works under android.

Oh ok, but when i load the ,properties, do i need to use GDx.files.internal or i can simply use the java file loader?

Read this, it’ll help. I would always use LibGDXs way though, why mix and match?
http://code.google.com/p/libgdx/wiki/FileHandling

Keeping in mind that ObjectOutputStream usually creates very deep call stacks, and that Android usually has a smaller stack allocated for applications than your typical desktop PC.

It isn’t a problem unless you go crazy with object serialization, but I’ve seen the problem posted before.

Just an FYI if you get stackoverflow when serializing objects on android.

if using libgdx and don’t want to use those
I would suggest Preferences

Can be pretty useful for most things, and works great in PC and Android

Best of all, its ridiculously easy to do!
For more complex things, I usually have something that embeds the data into some strings or whatever

Alright, i will try that!
Im just worried that i cant properly control where the file is hosted in pc…
it seems its hosted in /%username/bla bla bla ???

Yeah preferences default to that location, for me its
C:\Users\namro_000.prefs\

But on other systems, I’d sure it’d default somewhere.

It goes to an appropriate place for windows for that current user, why does it matter that you can’t save it somewhere else?

I did that and worked perfectly! Loved it!!!

Thanks guys, the issue is solved! For now :slight_smile:

On Linux, it goes into ~/.prefs

BTW, I wonder if users can edit this file on Android using some file manager? I’m storing the hiscore there, and I wouldn’t like users to be able to mess with it easily.

For game data like highscores, I’d recommend just using json and encrypting it.