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.

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
3  
Binary files are human readable too, it just requires a sufficiently skilled and motivated human. –  Adam Sep 15 '13 at 0:11

4 Answers 4

Libgdx has built in decoding and encoding functionality. Gustavo Steigert has written a nice article about this on his blog: http://steigert.blogspot.be/2012/03/5-libgdx-tutorial-files.html. 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
3  
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..

http://www.badlogicgames.com/forum/

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
1  
Read this badlogicgames.com/wordpress/?p=2305 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.

See: http://code.google.com/p/libgdx/wiki/Preferences

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);

or

prefs.putString("SecretInfo", myEncodeFunction("here's the secret text to save."));
share|improve this answer
up vote -1 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
4  
You should show what what callbacks you used. It'll be more useful for future visitors. –  Byte56 Apr 2 '12 at 19:54
1  
Does the Internal file type not solve your problem? code.google.com/p/libgdx/wiki/FileModule –  Rubber Mallet Apr 2 '12 at 20:08
2  
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

 
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.