gpt4 book ai didi

java - Android项目中的内部文件存储在哪里?

转载 作者:太空狗 更新时间:2023-10-29 13:43:11 26 4
gpt4 key购买 nike

在我的项目中,我必须制作一个文本文件并从该文件中读取详细信息。我需要知道我应该将文件放在目录中的什么位置,以便我可以在我的 Java 代码中成功读取它?

最佳答案

那应该放在/assets/

阅读本教程还可以了解 Android Beginners: Intro to Resources and Assets

AssetManager assetManager = getAssets();
InputStream stream = null;
try {
stream = assetManager.open("file.txt");
} catch (IOException e) {
// handle
}
finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {}
}
}

关于java - Android项目中的内部文件存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3228926/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com