1

I am working on quiz application. I stored the column data in the following form in sqlite database. enter image description here

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

Aerrow
  • 11,704
  • 10
  • 52
  • 89
RaagaSudha
  • 375
  • 5
  • 17
  • 38

4 Answers4

7

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"

Lalit Poptani
  • 65,659
  • 21
  • 155
  • 238
5

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.

NiVeR
  • 8,872
  • 4
  • 26
  • 34
2

getResources().getIdentifier(name,"drawable", getPackageName());

0

just name the src="image1.png" and put the files in your assets folder images and html