Use ActiveAndroid on existing database-content

和自甴很熟 提交于 2019-12-21 07:56:12

问题


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.

  1. The user has all of their data stored in a SQLite database and has not upgraded their app yet. [DB = SQlite v1]

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

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!