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.

1

1 Answer 1

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.

1
  • Thank you. I have found a way to work with the library using Uris
    – Maria
    Jun 24, 2014 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.