Modify and upgrade the sqlite Database
Today is the second day of work. I heard that my most recent task is to change the bug. Alas, when I learned the power, I recorded some problems.
Sqlite database is a very commonly used database in android. Today, we help others modify bugs and record some problems.
1. to modify the structure of a database table, you must upgrade the database. The database will automatically executeSQLiteOpenHelperInPublic void onCreate (SQLiteDatabase db ){}Method. to upgrade the database, you must callPublic void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion ){}To upgrade the database. If you modify the database version number (the version increases), the system will executeOnUpgradeMethod.
All Database modification operations are completed here.
2. Add fields to the database
Db.exe cSQL ("alter table" + PATIENTFOCUSDATA_TABLE_NAME + "add column 'account _ id' TEXT ");
PATIENTFOCUSDATA_TABLE_NAMEIndicates the Database Name,Account_idIndicates the newly added database field,TEXTIndicates the Data Type of the newly added field.