Android's operations on the SQLite database are incomprehensible. 1

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.