Android
AND-401 · Question #104
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…
The correct answer is A. if (cursor.moveToFirst()) {. See the full explanation below for the reasoning.
Question
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?
Options
- Aif (cursor.moveToFirst()) {
- Bdo {
- Cif (cursor.moveToFirst()) {
- Dif (cursor != null) {
How the community answered
(21 responses)- A76% (16)
- B5% (1)
- C14% (3)
- D5% (1)
Community Discussion
No community discussion yet for this question.