Android - load image from path -


in project have image localized in

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

when want load using

bitmap bitmap = bitmapfactory.decodefile("app\\src\\main\\res\\drawable\\informations\\angry_face.png"); this.image.setimagebitmap(bitmap); 

error occurs:

unable 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 set path resource?
thanks :)

you accessing resources wrongly:

try instead:

bitmap myangryimage = bitmapfactory.decoderesource(getresources(), r.drawable.angry_face); 

Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -