Consider the following code snippet:
String[] result_columns = new String[] {KEY_ID, COL1, COL2};
Cursor allRows = myDatabase.query(true, DATABASE_TABLE, result_columns,
null, null, null, null, null, null);
Which of the following prints out the values of COL1 column correctly if the result is not empty?
A.
if (cursor.moveToFirst()) {
do {
System.out.println(cursor.getString(1));
} while (cursor.moveToNext());
}
B.
do {
System.out.println(cursor.getString(0));
} while (cursor.moveToNext());
C.
if (cursor.moveToFirst()) {
do {
System.out.println(cursor.getString(0));
} while (cursor.moveToNext()); }
D.
if (cursor != null) {
do {
System.out.println(cursor.getString(1));
} while (!cursor.isNull());
}