Question

I am trying to open a Resource by passing the result of context.getResources().getString(R.drawable.myimage) to another class that is not an activity. context.getResources().getString(R.drawable.myimage) returns res/drawable-mdpi/myimage.png However, when I try and open this file, it throws a FileNotFoundException.

What is the proper way to open a resource outside an activity?

Was it helpful?

Solution

Can you post the code where you try to open the file.

res/drawable-mdpi/myimage.png is a relative path, not an absolute one. I guess you're not opening the correct path by using the relative and not absolute path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top