简体   繁体   English

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

[英]Where does Gdx search when i use Gdx.files.local(path)?

I'm using libgdx for a game. 我正在使用libgdx进行游戏。 I want to read/write text files to update highscores, very simple. 我想读/写文本文件以更新高分,非常简单。 I have three files already created placed in "$ANDROID-PROJECT/assets/data" , but Gdx seems to not find them when i use Gdx.files.local("data/file.txt"), but it does when i use Gdx.files.internal("data/file.txt"). 我已经在“ $ ANDROID-PROJECT / assets / data”中创建了三个文件,但是当我使用Gdx.files.local(“ data / file.txt”)时,Gdx似乎找不到它们,但是当我使用Gdx.files.internal(“ data / file.txt”)。 Because i need to also write the file, i'm forced to use Gdx.files.local. 因为我还需要写文件,所以我不得不使用Gdx.files.local。

Can anyone tell me Where does Gdx search when i use Gdx.files.local(path) ? 谁能告诉我使用Gdx.files.local(path)时Gdx在哪里搜索? what path should i specify ? 我应该指定什么路径?

code: 码:

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

if anybody have this problem, i solved by changing Gdx.files.local for Gdx.files.external. 如果有人遇到此问题,我可以通过将Gdx.files.local更改为Gdx.files.external来解决。 This way the files are stored in the SD Card, it has the same functionality of R/W files as local but in the SD Card. 这样,文件存储在SD卡中,它具有与本地文件相同的R / W文件功能,但在SD卡中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM