SQLite database reports

Source: Internet
Author: User
I debugged a piece of code today and reported the-1 error (no corresponding row or column is found based on the row or column name ). The first thought was whether there was a problem with the corresponding database. After searching for a long time, I found that all the columns were missing and the column names were not wrong. Another thought is that the database structure changes and the application needs to be re-installed, so the re-deployment on the mobile phone still reports the same error.

I debugged a piece of code today and reported the-1 error (no corresponding row or column is found based on the row or column name ). The first thought was whether there was a problem with the corresponding database. After searching for a long time, I found that all the columns were missing and the column names were not wrong. Another thought is that the database structure changes and the application needs to be re-installed, so the re-deployment on the mobile phone still reports the same error.

I debugged a piece of code today and reported the-1 error (no corresponding row or column is found based on the row or column name ). The first thought was whether there was a problem with the corresponding database. After searching for a long time, I found that all the columns were missing and the column names were not wrong. Another thought is that the database structure changes and the application needs to be re-installed, so the re-deployment on the mobile phone still reports the same error.

Finally, I found the problem. It was a small mistake: when defining the Cursor, the second parameter of the query () function requires the corresponding column name! Cursor returns a sub-table, and all the remaining query results are processed only based on the sub-table. Therefore, even if the original database defines rows or columns, if the child table returned by Cursor does not contain them, an error is returned! After the database is added, the database returns to normal.


PS: Another tips: when the data in the database cannot be directly stored as a txt file on the SD card on the mobile phone for some reason (for example, zWatch I am developing cannot store any files at all ), you can write a function to read all the data in the database in the form of logs, and then manually save it. Never get bored.

Smaller details: "/n" in the Log file does not represent line breaks ..

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.