Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Writing my game in libgdx, I arrived at the point when I need to save the player stats and the info of the levels. However, in libgdx it's not allowed to write the file inside folder of the application, only external (on the SD) is allowed. The point is that I don't want the file to be seen by anyone, or if they can see it, how can I convert it to a binary file so it's not human readable? I just want to hide the file.

share|improve this question
Binary files are human readable too, it just requires a sufficiently skilled and motivated human. – Adam Sep 15 '13 at 0:11

Libgdx has built in decoding and encoding functionality. Gustavo Steigert has written a nice article about this on his blog: Scroll down a bit to the section "2. Persist Profile operation".

In this blogpost, he explains that by using the class com.badlogic.gdx.utils.Base64Coder you can encode and decode files in the Base64-format. Leaving the unreadable and unmodifiable for end users.

share|improve this answer
While better than plaintext base64 is visually recognisable and web based en/decoding tools are a search away. – Kelly Thomas Apr 16 '13 at 20:53

Again, try asking here..

Basically, you may want to read up on how Android handles directories in your app. There is a file handle class in libgdx that should work for you. If you just want it saved in a protected place, use the internal process and it should be local to your app directory and not visible. It doesn't have to be on an sd card. Read the android docs and ask on the badlogic forum if you still need help and don't get any answers here

share|improve this answer
libgdx doesnt let you write files internally, i resolved it making a callback to a method in Android, because Android can write it. Thanks – Rudy_TM Feb 17 '12 at 15:16
Read this I believe it could be what you need. – arielsan Mar 19 '12 at 2:55
@Rudy_TM please add your comment as an answer and select it as the accepted answer so other people who read this later can clearly see it. – ashes999 Apr 2 '12 at 10:57

It sounds like using a "preference" is what you need to do. It allows you to save small bits of data (like a high score, or other settings) which persist when the game is shut down.

And it's a lot easier than trying to write to a file; you don't really have to concern yourself where the file is.


On Windows it gets put in the user's home directory. Android uses a SharedPreference system.

If you don't want users being able to read what's in there, you can always save your values in an encoded way. Ex:

prefs.putInteger("HighLevel", 15);


prefs.putString("SecretInfo", myEncodeFunction("here's the secret text to save."));
share|improve this answer
up vote -2 down vote accepted

I resolved it with callbacks, with that I can use Android methods, that way I can write to the internal memory.

share|improve this answer
You should show what what callbacks you used. It'll be more useful for future visitors. – Byte56 Apr 2 '12 at 19:54
Does the Internal file type not solve your problem? – Chuck D Apr 2 '12 at 20:08
You actually shouldn't use callbacks unless you don't want to use latest LibGDX... "local" files have been added as mentioned on blog to allow saving to private app directory – XiaoChuan Yu Apr 3 '12 at 0:14
I didnt know, i did the code like 2 months ago :/ i will change it :) thaks – Rudy_TM Apr 3 '12 at 20:46
@RubberMallet no, that doesnt do the trick, because it only reads, it doesnt write, see the part of the blog that put XiaoChuan Yu, thats the new stuff for files (its of type local) :) – Rudy_TM Apr 3 '12 at 20:49

Your Answer


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.