2

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
  • 12,086
  • 10
  • 56
  • 90
RaagaSudha
  • 397
  • 5
  • 17
  • 38

4 Answers4

8

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
  • 67,150
  • 23
  • 161
  • 242
6

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
  • 9,644
  • 4
  • 30
  • 35
2

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

0

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