Reputation: 1346
HI I am trying to run a LibGDX application on Android and I try to load a JSON File where I need read/write access.
That file is in the assets folder.
When I try to load it with Gdx.files.local("file.json"), it says that it cannot be found (it works with Gdx.files.internal(), however then it is read-only).
Actually, that worked well in another project, and, somehow, now it does not.
I searched for an answer and I cannot find anything, do you have an idea how to solve that problem?
Upvotes: 0
Views: 1246
Reputation: 9823
According to the documentation of Libgdx FileHandle
types, the Local
and Internal
FileHandle
s use a different path under the hood:
- The Internal
FileHandle
is relative to the assets directory on Android and has a fall back to the ClassPath
FileHandle
. It is always read-only!
- The Local
FileHandle
is relative to the internal (private) App-Storage on Android. You can use this FileHandle
to read and write.
So basicly it is not possible to write to a file in the internal stoarage, use the local storage instead.
As you want to "ship" this file with your application, you might want to copy it from internal to local storage when the app is started for the first time, so that the application has read and write access to it.
Upvotes: 1