简体   繁体   中英

I made a change to sqlite ntable and I was wondering how do I update it in my onupgrade?

I made a change to my DB Adaptor I added a new column and I was wondering how do I add it to all the people who have older versions of my app? Am I supposed to change DATABASE_CREATE with the column or do I just add it to onupgrade. If I am just supposed to add it to onupgrade can someone show me an example?

Thanks

Increase your database version for your database, and in your on upgrade do something like this

if (oldVersion == 2)
    upgradeToVersion3();

Then in that method you can use ALTER TABLE . But I am not sure whether or not the version Android use actually has support for adding extra columns. If not, you'll have to rename the table, create the new table, and then do a page lookup with a INSERT INTO table (column1, column2) SELECT column1 FROM tmp_table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM