0

I'm working with a library and I need to get a file path stored at raw folder, so library methods create a FileInputStream, but I always get a FileNotFoundException from library methods.

So I have created a class and try:

String path = "android.resource://" +context.getPackageName () + "/" + "myFileName"; 
InputStream fis2 = getResources().openRawResource(R.raw.myFileName);
File f = new File(path);

fis2 and f are correctly created and I get no FileNotFoundException.

But when I try: FileInputStream fis = new FileInputStream(path); I get the FileNotFoundException.

Maria
  • 334
  • 3
  • 17
  • possible duplicate of [How to read file from res/raw by name](http://stackoverflow.com/questions/15912825/how-to-read-file-from-res-raw-by-name) – Ultimo_m Jun 23 '14 at 19:23

1 Answers1

0

I need to get a file path stored at raw folder

That is not possible, as it is not a file.

so library methods create a FileInputStream

Those library methods need to be adjusted to work with an ordinary InputStream. Then, use your fis2 InputStream.

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