问题
I developed an Android-App where I saved data in a SQLite database using the SQLiteOpenHelper.
I am wondering if I could update my app by using ActiveAndroid, but in a way that the user data previously stored in the database will be preserved.
Is that possible?
回答1:
You would have to perform a data migration during runtime after the user upgrades to the newest version of the app. The process could be broken down into the following steps, I have also assigned database version values to each step.
The user has all of their data stored in a SQLite database and has not upgraded their app yet. [DB = SQlite v1]
On upgrade, when the user is upgrading to the next version of the app read all data from the old SQLite database and store it into the ActiveAndroid database. [DB = SQLite v1 and ActiveAndroid v1]
Once all of the data has been migrated to the new ActiveAndroid database then delete all tables of the SQLite database so that you don't use extra storage space that you do not need. [DB = SQLite v2 and ActiveAndroid v1]
In the next release you can then assume that user has had their data fully migrated and at this point it is finally safe to remove all code that was previously referencing the SQLite database. [DB = ActiveAndroid v2]
来源:https://stackoverflow.com/questions/28569599/use-activeandroid-on-existing-database-content