Opening a resource outside an activity in Android
-
25-09-2019 - |
문제
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?
해결책
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.
제휴하지 않습니다 StackOverflow