I'm using a SQLite database on Android and I need a particular value from the table. I have a DataBaseHelper class.
private static final String TABLE_NAME = "my_task";
private static final String COL1 = "ID";
private static final String COL2 = "name";
private static final String COL3 = "status";
private static final String COL4 = "rec";
I have to get the value of column rec for the given name (it's either 0 or 1). I have this function to do the task:
public Cursor getRec(String task) {
SQLiteDatabase db = this.getWritableDatabase();
String q = "SELECT " + COL4 + " FROM " + TABLE_NAME + " WHERE " + COL2 + " = ?";
Cursor data = db.rawQuery(q, new String[] { task });
return data;
}
I don't know how to get the required value from this returned cursor. I'm new to this, so please help me with this.