Java. lang. IllegalArgumentException: column '_ id' does not exist, doesnotexist
When you use SimpleCursorAdapter to display SQLite data to ListView, the error java. lang. IllegalArgumentException: column '_ id' does not exist is displayed, indicating that the field "_ id" does not exist.
Let's take a look at the inheritance relationship of SimpleCursorAdapter, and you will know why:
We can see that SimpleCursorAdapter inherits ResourseCursorAdapter, while ResourseCursorAdapter inherits CursorAdapter. Now let's take a look at the description of CursorAdapter:
Adapter that exposes data fromCursor
ToListView
Widget. The Cursor must include a column named "_ id" or this class will not work.
The adapter displays data from the cursor to the ListView view control. The cursor must contain a column named "_ id" or the class will not work.
At this time, we can understand that when we query the SQLite database, the query field does not contain "_ id", so the cursor does not have the "_ id" field. In SimpleCursorAdapter (Context context, int layout, Cursor c, String [] from, int [] to), a column corresponding to "_ id" must also exist to succeed.
So the solution is: the query field must contain "_ id", and the from in the constructor of SimpleCursorAdapter must also have "_ id" corresponding to the query field ", you can solve the problem.