开发者

Android update - perform database actions

I don't exactly know how android updates the applications. As far as I've read around here it keeps the SQLite database. So, imagine this scenario: one application that uses S开发者_StackOverflow中文版QLite database for persisting data. After a while I release v2 which contains some database changes and I need to update user data in database. How can I make this during the update process ?


See SQLiteOpenHelper#onUpgrade. Subclass the SQLiteOpenHelper class and do all the stuff to update the tables in the onUpgrade method.

As you will see, the constructor of SQLiteOpenHelper takes as last parameter the Database version:

version: number of the database (starting at 1); if the database is older, onUpgrade(SQLiteDatabase, int, int) will be used to upgrade the database

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜