Cause of error: When querying the entire SQLite database, there is no query to the "_id" column.
The original code is: Msqlitedatabase.query (table_name, new string[] {_title}, NULL, NULL, NULL, NULL, NULL);
The modified code is: msqlitedatabase.query (table_name, NULL, NULL, NULL, NULL, NULL, NULL);
Here the new string[] {myevent._title} is a query condition, the contents of the array is to query the table column name, here is the limit you want to query the column. A parameter value of NULL indicates that all columns are queried (containing the column "_id"). Such changes are also possible: msqlitedatabase.query (table_name, new string[] {_id, _title}, NULL, NULL, NULL, NULL, NULL); The goal is to have the "_id" column in the results of your query.
In addition, about the "_id" column in the SQLite database, it must be in the SQLite database, and the column name must also be "_id" general primary key. The "_id" column is also required when the following code is displayed in a ListView.
public void Updataadapter () {
if (mcursor! = NULL &&!) Mcursor.isclosed ())
mcursor.close ();
mcursor = m_ Mydatabaseadapter.fetchalldata ();
mcursor.movetofirst ();
if (mcursor! = null && Mcursor.getcount () > 0) {
listadapter adapter = new Simplecursoradapter (this, Android. R.layout.simple_list_item_1, Mcursor, new string[] {_title}, new int[] {Android. R.ID.TEXT1});
listview.setadapter (adapter);
}
}
The simplecursoradapter shown here will be displayed according to "_id", "_id" is a must.
Android caused By:java.lang.IllegalArgumentException:column ' _id ' does not exist