(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