There is a database, created a query that returns a single row with 12 columns:

String selectQuery = "SELECT * FROM MyTable WHERE _id = "+id; Cursor cursor = db.rawQuery(selectQuery, null); 

How now it is possible to bring the data from these 12 columns in an array?

  • To work with data obtained from the database, the Cursor class is used, which allows you to read the received information, move the pointer to the current element and some others. For full-fledged work, it is desirable to become familiar with all of its methods - pavlofff

1 answer 1

 if (cursor.moveToFirst()) { ArrayList<String> values = new ArrayList<>(); for (String columnName : cursor.getColumnNames()) { values.add(cursor.getString(cursor.getColumnIndex(columnName))); } for (String value : values) { Log.d("TAG", value); } }