SQLite Database Modification and upgrade

Source: Internet
Author: User
Tags sqlite database

Today is the second day of work, I heard that my recent task is to change the bug, alas, when the right to learn, some of the problems encountered are recorded.

SQLite database is a very common in Android database, today to help others fix bugs, encountered some problems recorded.
1. Modify the structure of the database table to be implemented through a database upgrade, the database will automatically execute SQLiteOpenHelper methods in the inheriting class, public void onCreate(SQLiteDatabase db) {} if the database is to be upgraded, you need to call the public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){} method to implement the database upgrade function, if you modify the database version number (version becomes larger), the system will execute onUpgrademethod.
All database modification operations are done here.
2. Add a field to the database

db.execSQL("ALTER TABLE "+PATIENTFOCUSDATA_TABLE_NAME+" ADD COLUMN ‘account_id‘ TEXT ");

PATIENTFOCUSDATA_TABLE_NAMERepresents the database name, which account_id represents the newly added database field, which TEXT represents the new data type of the added field.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

SQLite Database Modification and upgrade

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.