0

In my project I have image localized in

app\src\main\res\drawable\informations\angry_face.png

When I want to load it using

Bitmap bitmap = BitmapFactory.decodeFile("app\\src\\main\\res\\drawable\\informations\\angry_face.png");
this.image.setImageBitmap(bitmap);

Error occurs:

Unable to decode stream: java.io.FileNotFoundException: app\src\main\res\drawable\informations\angry_face.png: open failed: ENOENT (No such file or directory)

Question is: How to set the path to this resource?
Thanks for help :)

1 Answer 1

1

You are accessing the resources wrongly:

Try this instead:

Bitmap myAngryImage = BitmapFactory.decodeResource(getResources(), R.drawable.angry_face);
1
  • Good idea. But what to do when I want to organize my images into subfolders? How to load images in this kind of situation?
    – Wicia
    Apr 19, 2016 at 18:30

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.