How can i get an image from drawable using image name stored in SQLite?

I am trying to develop an Android quiz app using SQLite.My Database has a table containing the Questions and answers. Questions may have text or images. So i put images in drawable and the name in a column of Quiz table. I tried to load the content of the image (using the value of that column) in the ImageView associated to each one of my quiz questions but im not sure if i used the right code.I don't want to use blobs. Any suggestion ? Any answer will be much appreciated. Thank you.

That's what i thought to write so to call the image from db and drawable:

 `String  y =  "R.drawable."+currentQuestion.getImage();
           tvImgQuest.setImageResource(Integer.parseInt (y));`

Solution 1:

Drawable id is an integer and it's not a string that you can convert to integer your code must be this:

Context context =tvImgQuest.getContext();
int id = context.getResources().getIdentifier(name, "drawable", context .getPackageName());
tvImgQuest.setImageResource(id);