So yeah, I've seen questions about this all over the place, and so have accordingly added an _id
alias to my query as below:
SimpleCursorAdapter sca = new SimpleCursorAdapter(getActivity(),
R.layout.activity_contact_list, cursor, new String[] {
"rowid _id", DBOps.COL_CATNAME },
new int[] { R.id.contact_list }, CursorAdapter.NO_SELECTION);
I'm creating my cursor like so:
public Cursor getAllCategories() {
return mDB.query(TABLE_NAME, new String[] { "rowid _id", COL_ID,
COL_CATNAME,
COL_ICONPATH }, null, null, null, null, null);
}
mDB
in the above is a SQLite database.
I've tried changing the string to rowid as _id
, which also doesn't work. Also apparently there's no need to change my table structure by adding another _id
column as a few others have noted, so where am I going wrong here?
Update - here's the stack trace -
Caused by: java.lang.IllegalArgumentException: column 'rowid _id' does not exist
at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:303)
at android.widget.SimpleCursorAdapter.findColumns(SimpleCursorAdapter.java:333)
at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:107)
at com.rex.bizcontacts.ContactListFragment.onCreate(ContactListFragment.java:77)