Reputation: 565
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 :)
Upvotes: 0
Views: 478
Reputation: 48258
You are accessing the resources wrongly:
Try this instead:
Bitmap myAngryImage = BitmapFactory.decodeResource(getResources(), R.drawable.angry_face);
Upvotes: 1