I am developing a small online shopping application in Android which needs to have lot of items images, I have a web service which gives the path of image present in android drawable-mdpi, My problem here that I tried this code to get the imageresource id, but it always gives me 0.
String uri = "@drawable/bangle1.png";
int imageResource = getResources().getIdentifier(uri, null, getPackageName());
Is there any method, to get resource id, so that I can use it for drawable like :
Drawable res = getResources().getDrawable(imageResource);
I tried googling but most of them suggested the above method and this gives me always 0 value. Any one please help here.