开发者

Are databases deleted when an application is updated?

开发者 https://www.devze.com 2023-01-22 20:05 出处:网络
I added a table to a database that my application uses and wrote some code to work with that table. Everything worked fine for my on my phone and in the emulator, so I sent the update to the market.

I added a table to a database that my application uses and wrote some code to work with that table. Everything worked fine for my on my phone and in the emulator, so I sent the update to the market.

This cause me to receive quite a few开发者_如何学C stack traces in the developers console cause by

android.database.sqlite.SQLiteException: no such table: flag

(flag is the new table).

This got me to wondering, are databases deleted when the application is updated? Presently in my application I am looking to see if the database exists, and if it does then I don't recreate it.

I didn't catch this before I sent out the update because I uninstalled the application before uploading the debug version.

I've since rolled out a quick update that has a try catch blocks around all accesses to the new table(which should have been there in the first place, I know, I know).


User data is not deleted, including databases.

Your DB has a version number. When you update your app, you advance the version number so that you can detect a present "old" DB.

This can be used to trigger a migration routine. In your case it should have added new table to the DB.


SQLiteOpenHelper is the answer.

0

精彩评论

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