Reputation: 4948
I have a method that i pass an id to and then want to find the row in that table that matches the id, and returns a string that is the colLabel of that row:
public String getIconLabel(int id){
String label;
String selectQuery = "SELECT "+colL" FROM " + allIcons + " WHERE " +colIconID + "="+id;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
label = //HELP
return label;
}
I am unclear as to how to set label to be that specific column of the selected row?
please help
Upvotes: 3
Views: 9528
Reputation: 66637
if(cursor != null)
{
cursor.moveToFirst();
String label = cursor.getString(0);
}
0 parameter represents your column index. Refer this link.
Upvotes: 4
Reputation: 4897
if (null != cursor && cursor.moveToFirst()) {
label = cursor.getString(cursor.getColumnIndex(COLUMN_ID));
}
Upvotes: 8