0

If I want to access a directory, I would to the following:

File f = new File(getFilesDir()+"/name");

And then, if f is a directory, I can iterate through the files and do a lot of things.

Can I do the same with the drawable/raw folder? I know how to get the id of a file using the name or the name using the id, but I am not sure how can I use drawable as a directory. I also need to use FileInputStream on some files, so I need a file type, not an id or a name.

I found some 'some what' related questions, like this one: Retrieving all Drawable resources from Resources object

But my problem is a bit different. I know how to get a resource in this way. By getting the id you can do lots of things, but as far as I know, you can not use FileInputStream. That's what I need: the possibility to use FileInputStream on a resource that is inside a project folder(drawable or raw).

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Florin
  • 43
  • 4
  • Copy the files in the internal storage! And start using them its easy especially when they are in assets folder – Xenolion Aug 25 '17 at 01:43

1 Answers1

0

Can I do the same with the drawable/raw folder?

Not really.

the possibility to use FileInputStream on a resource that is inside a project folder(drawable or raw)

Resources are not files. You cannot get a FileInputStream on them.

For raw resources, you can call openRawResource() on a Resources object to get an InputStream, though.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491