android-cursor
Android Studio – Value must be ≥ 0
I had an error like this. My solution : change method getColumnIndex into getColumnIndexOrThrow.
How can I create a list Array with the cursor data in Android
Go through every element in the Cursor, and add them one by one to the ArrayList. ArrayList<WhateverTypeYouWant> mArrayList = new ArrayList<WhateverTypeYouWant>(); for(mCursor.moveToFirst(); !mCursor.isAfterLast(); mCursor.moveToNext()) { // The Cursor is now set to the right position mArrayList.add(mCursor.getWhateverTypeYouWant(WHATEVER_COLUMN_INDEX_YOU_WANT)); } (replace WhateverTypeYouWant with whatever type you want to make a ArrayList of, and WHATEVER_COLUMN_INDEX_YOU_WANT with the column index … Read more
Create a cursor from hardcoded array instead of DB
Check out the MatrixCursor documentation. Check for instance this example. String[] columns = new String[] { “_id”, “item”, “description” }; MatrixCursor matrixCursor= new MatrixCursor(columns); startManagingCursor(matrixCursor); matrixCursor.addRow(new Object[] { 1, “Item A”, “….” }); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.layout_row, matrixCursor, …); setListAdapter(adapter);