I want to save the state of the game in a file, so I can read it at the next start. The Problem is, that I get a exception, if I try to save something internal. If I try to save it local all work fine. I save the file as a Json.
Bird bird = new Bird();
bird.setName("Foo");
bird.setSkin(new Texture("data/foo.png"));
bird.save(Gdx.files.internal("bird.json"));
The save mthod:
Json json = new Json();
file.writeString(json.prettyPrint(this), false);
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Error writing file: bird.json (Internal) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java:349) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java:335) at com.buschmannmichael.fattybird.core.Bird.save(Bird.java:31) at com.buschmannmichael.fattybird.game.FattyBirdGame.create(FattyBirdGame.java:16) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:137) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:115) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Cannot write to an internal file: bird.json at com.badlogic.gdx.files.FileHandle.writer(FileHandle.java:315) at com.badlogic.gdx.files.FileHandle.writeString(FileHandle.java:346) ... 5 more
Whats the problem of LibGDX, where I should save the files, so I can run the game on android, desktop and html ? (I tested this method I showed above only on desktop, maybe it works on android but I want a solution for all platforms)
Maybe someone can help me :)