SQLite database Create, delete, downgrade notes

Source: Internet
Author: User
Tags sqlite sqlite database

(1), when you create a SQLite database, you need to be aware that the OnCreate () method runs only when the database is first created. When the database is deleted and also executed, SQLite does not support database deletion, but can delete the corresponding file, that is, deleted the database. OnCreate () is executed when we configure the file again.

(2), Onupgrade () only when the version number changes (increase) will be executed, many times we directly in the Onupgrade () to add the table or column we want to insert, but will error, it is because your previous version of the Onupgrade statement will be executed again, if the table was inserted before , or line, this time will be executed again, so each time with the new database needs to comment or delete all the previous statements (for the database reply, etc., it is best to save the previous operation)

public void Ondowngrade (sqlitedatabase db, int oldversion, int newversion) {$         /**47          * Perform a degraded operation of the database          * 1, Only when the new version is lower than the old version will execute          the 2, if not perform the demotion operation, will throw an exception of the          */51         log.i ("person", "* * * * * * * * *:" + db_version);         Super.ondowngrade (db, Oldversion, newversion);     

(3) Sqiite supports the insertion of columns, but does not support deletion, so it is unclear how to delete columns, I generally save the data after deleting the table and then rebuilding.

SQLite database Create, delete, downgrade notes

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.