문제

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 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top