java 如何将txt文件添加到您的android项目中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34829786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 23:25:05  来源:igfitidea点击:

How to add a txt file into your android project?

javaandroid

提问by Wrestling with Android

I have version 1.5.1 of Android studio. Apparently this never version doesn't have an asset folder for txt files. How are you suppose to includes these files into you project? And how to further use the within you application? Thanks for your advice

我有 Android Studio 1.5.1 版。显然,这个从不版本没有用于 txt 文件的资产文件夹。您打算如何将这些文件包含到您的项目中?以及如何在您的应用程序中进一步使用?谢谢你的建议

回答by ??????

Project window, press Alt-Insert, and select Folder->Assets folder. Android Studiowill add it automatically to the correct location.

Project window,按Alt-Insert,然后选择Folder->Assets folderAndroid Studio会自动将其添加到正确的位置。

And then you can add your assets or/txt files(whatever you want) on it.

然后您可以在其上添加您的资产或/txt 文件(无论您想要什么)。

回答by Alan S.

You can go to New->add folder -> assets folder and the folder will automatically be put in the right place.
Please reference the following where I got this answer -- it also includes a screenshot: Adding an assets folder in Android Studio

您可以转到新建->添加文件夹->资产文件夹,该文件夹将自动放在正确的位置。
请参考以下我得到这个答案的地方——它还包括一个屏幕截图: 在 Android Studio 中添加一个资产文件夹

To access something from the assets folder in your application you need to use the AssetManager:

要从应用程序中的资产文件夹访问某些内容,您需要使用 AssetManager:

Please refer to the following for a full example:

有关完整示例,请参阅以下内容:

How to access file under assets folder?

如何访问assets文件夹下的文件?