3

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

2 Answers 2

8
if (null != cursor && cursor.moveToFirst()) { label = cursor.getString(cursor.getColumnIndex(COLUMN_ID)); } 
Sign up to request clarification or add additional context in comments.

Comments

4
if(cursor != null) { cursor.moveToFirst(); String label = cursor.getString(0); } 

0 parameter represents your column index. Refer this link.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.