Arash.Ch Arash.Ch - 24 days ago 18
Android Question

Get the value from the cursor in Android SQLite

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 know idea what it is.

Thanks in advance

here's my code:

meeting.setPlace(cursor.getString(cursor.getColumnIndex("place")));

Answer

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.

Comments