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 ie 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
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 ie - "image1"
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.
getResources()。getIdentifier(name,“ drawable”,getPackageName());
只需命名src =“ image1.png”并将文件放在资产文件夹图像和html中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.