Today, when I learned how to operate the SQLite database on Android, I wrote the following table:
String tablecreate = "create table" + tablename + "(key_id integer primary key, key_name text, key_sex text )";
However, a normal cursor (cursor) can be returned during the query, but data cannot be output to the outside. I do not know why, later, it took only half a day to find that the _ id item must exist in the table. Otherwise, no data is output and the following error is always reported:
Column _ id does not exist (column _ id not exists). I don't know why. I will record it first, and then I will find it again. I also want to leave a message for a friend who knows it.
My query statements are as follows:
Cursor cursor = baseadapter. Select (); If (cursor! = NULL & cursor. getcount ()> 0) {try {listadapter adapter = new simplecursoradapter (this, R. layout. listviewitems, cursor, new string [] {"_ id", "key_name"}, new int [] {R. id. text1, R. id. text2}); listview. setadapter (adapter);} catch (exception e) {log. I ("errorerrorerroe", E. getmessage ());}}
You can use _ id to return data normally. If you do not need it, you cannot return data normally!