سؤال

I plan to develop an android application for list with image and text.how can i save the image path(R.drawable.image) in sq lite db and then fetch that path and set to image view.for list items.

هل كانت مفيدة؟

المحلول

If you want to read an image from drawable directory, but you have only the image name (NO the image path) you could get them from an activity like this:

Resources res = getResources();
int resId = res.getIdentifier("MY_IMAGE", "drawable", getPackageName());
if(resId==0) 
     throw new Exception("drawable resource not found");
Drawable drawable = res.getDrawable(resId);

And, in your drawable dir you will have a MY_IMAGE.png o what else.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top