Reputation: 397
I am working on quiz application. I stored the column data in the following form in sqlite database.
I am able to retrieve the question but now I need to retrieve the image of that particular question. I kept the images in drawable folder. But I need to change the i.e src="/test/image1.png" to src="/drawable/image1.png"
. If I change the path like the path of the
image in sqlite colum at then can I get the image which I kept in my drawable folder? Please help me regarding this...
Thanks in advance
Upvotes: 2
Views: 18540
Reputation: 763
just name the src="image1.png" and put the files in your assets folder images and html
Upvotes: 0
Reputation: 9806
It can be done like this aswell:
Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
where this refers to the context of the actual activity.
Upvotes: 6
Reputation: 71
getResources().getIdentifier(name,"drawable", getPackageName());
Upvotes: 2
Reputation: 67296
I would insist that in database you can just give the name of the image and then you can get the image using getIdentifier
,
getResources().getIdentifier(name,"drawable", getPackageName());
Where name will be the name of your image i.e - "image1"
Upvotes: 7