sqlite Android - 如何获取特定col/row的值

eri*_*rik 3 sqlite android

我有一个方法,我传递一个id,然后想要找到该表中与id匹配的行,并返回一个字符串,该行是该行的colLabel:

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;

    }
Run Code Online (Sandbox Code Playgroud)

我不清楚如何将标签设置为所选行的特定列?

请帮忙

jsm*_*ith 6

if (null != cursor && cursor.moveToFirst()) {
    label = cursor.getString(cursor.getColumnIndex(COLUMN_ID));
}
Run Code Online (Sandbox Code Playgroud)