当我使用 Gdx.files.local(path) 时,Gdx 在哪里搜索



我正在使用libgdx进行游戏。我想读/写文本文件来更新高分,非常简单。我已经在"$ANDROID-PROJECT/assets/data"中创建了三个文件,但是当我使用Gdx.files.local("data/file.txt")时,Gdx似乎找不到它们,但是当我使用Gdx.files.internal("data/file.txt")时却找到了。因为我还需要写入文件,所以我被迫使用 Gdx.files.local。

谁能告诉我当我使用 Gdx.files.local(path) 时 Gdx 在哪里搜索? 我应该指定什么路径?

法典:

//for read
FileHandle file = Gdx.files.local("data/scoresCla.txt");
clasico = Float.parseFloat(file.readString());
//for write
FileHandle file = Gdx.files.local("data/scoresCla.txt");
file.writeString(String.valueOf(res), false);

如果有人有这个问题,我通过将Gdx.files.local更改为Gdx.files.external来解决。这样,文件存储在SD卡中,它具有与本地文件相同的R/W文件功能,但在SD卡中。

最新更新