I am displaying an image in my ListView. I stored the image in my drawable folder R.drawable.image. Eveything is working great
AddObjectToList(R.drawable.image)
Howver now I decided to sore the location in my sqllite db as a string “R.drawable.image“. I need to parse it into a integer so I did this:
AddObjectToList(Integer.parseInt(imageelist3.get(i).toString()
Getting this error
ComponentInfo{myproject}: java.lang.NumberFormatException: unable to parse 'R.drawable.image' as integer
Any idea how to resolve?
First of all, you have to understand the meaning of
R.drawable.imageHere R is a
class Rof auto-generated java file from android application,which contains other class
class drawablein thatimage is a int variable.Its a int value and you are storing it as string then converted it in int which is wrong.
Just store int values of R.drawable.image.