you can do by uri
String uri = "@drawable/imname"; //imname without extension
int imageResource = getResources().getIdentifier(uri, null, getPackageName()); //get image resource
Drawable res = getResources().getDrawable(imageResource); // convert into drawble
imageView.setImageDrawable(res); // set as image
Try this:
String uri = "@drawable/myresource"; // where myresource (without the extension) is the file
int imageResource = getResources().getIdentifier(uri, null, getPackageName());
imageview= (ImageView)findViewById(R.id.imageView);
Drawable res = getResources().getDrawable(imageResource);
imageView.setImageDrawable(res);