SQLite database Changes and upgrades

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, right when learning, some of the problems encountered are recorded.

The SQLite database is a very frequently used database in Android. Today to help others change the bug, encountered some problems recorded.
1. Change the structure of the database table to be implemented through the database upgrade, the database will run its own SQLiteOpenHelper method of inheriting classes, if public void onCreate(SQLiteDatabase db) {} the database to upgrade, you need to call public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){} the method to implement the database upgrade function, if you change the database version number (version number becomes larger), The system will run the onUpgrade method.
All the database changes are complete 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, TEXT representing the data type of the newly added field.

SQLite database Changes and upgrades

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.