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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -