1String uri = "@drawable/myresource"; // where myresource (without the extension) is the file
2
3int imageResource = getResources().getIdentifier(uri, null, getPackageName());
4
5imageview= (ImageView)findViewById(R.id.imageView);
6Drawable res = getResources().getDrawable(imageResource);
7imageView.setImageDrawable(res);
1String fnm = "cat"; // this is image file name
2String PACKAGE_NAME = getApplicationContext().getPackageName();
3int imgId = getResources().getIdentifier(PACKAGE_NAME+":drawable/"+fnm , null, null);
4System.out.println("IMG ID :: "+imgId);
5System.out.println("PACKAGE_NAME :: "+PACKAGE_NAME);
6// Bitmap bitmap = BitmapFactory.decodeResource(getResources(),imgId);
7your_image_view.setImageBitmap(BitmapFactory.decodeResource(getResources(),imgId));