Why always null is returned even when c.moveToFirst() is true and the program start to execute this row:result = c.getString(0);String rows[] = new String[] {KEY_GAL_ID}; Cursor c = ourDatabase.query(GALLERY_TABLE, rows,KEY_ROWID + "=" + rowId,null, null, null, null); String result = ""; if(c.moveToFirst()) { result = c.getString(0); return result; } else{ return "null"; }