-1

In Android Studio, If we want to use an image in our Anroid app, we move this image to res/drawable file. And we use it.

But if we want to use contents of a .txt file (e.g reading text from file at the first launch the app), which directory should we move this file?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Be Studios
  • 49
  • 4

3 Answers3

4

You can put it on res/raw or in assets/ directory.

glagarto
  • 913
  • 8
  • 20
  • There is no `assets/` folder or `res/raw` folder in my file system of Android Studio project. – Be Studios Jul 04 '18 at 07:51
  • Read https://stackoverflow.com/questions/18302603/where-do-i-place-the-assets-folder-in-android-studio. – ADM Jul 04 '18 at 07:55
  • 1
    You have to create for yourself. Here's how: Right click the res folder > New > Folder > Assets Folder/Raw Resources Folder. As of now, Android Studio does not have specific folder for .txt files. – glagarto Jul 04 '18 at 07:59
0

Just create folder assets like this:

like this

Or create folder raw in res and you can put there whatever you want:

enter image description here

Alexander Tumanin
  • 1,638
  • 2
  • 23
  • 37
0

It depends on using file.For example for reading text file, any movement is needed. You can read it from asset directory.

But if you want to write in a text file, you must move it to internal/external memory in a directory you have set in your code.