0

I used the below code to get the "place" value from the "place" column using a cursor. The value of the place in my database is a string,but It returns a number that I have no idea what it is.

here's my code:

meeting.setPlace(cursor.getString(cursor.getColumnIndex("place")));
zombie
  • 5,069
  • 3
  • 25
  • 54
  • `cursor.getString` always returns a string, not a number. Sounds like you inserted the data incorrectly into the database – OneCricketeer Nov 08 '16 at 19:14
  • @cricket_007 first of all thanks for correcting my mistakes. I think I've inserted them correctly...here it is: contentValues.put("place",R.string.consert7_place); db.insert(TBL_MEETING,null,contentValues); – A. Arash Chitgar Nov 08 '16 at 19:16

1 Answers1

0

I think I've inserted them correctly... here it is:

contentValues.put("place",R.string.consert7_place);  
db.insert(TBL_MEETING,null,contentValues); 

R.string.consert7_place is an integer, not a String.

You need to use getResources().getString(R.string.consert7_place)

For more details, see Android: How do I get string from resources using its name?

Your cursor.getString usage is fine.

Community
  • 1
  • 1
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245