Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ActiveAndroid on existing database-content

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?

like image 352
deimos1988 Avatar asked Feb 17 '15 19:02

deimos1988


1 Answers

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]

like image 187
Andrea Thacker Avatar answered Oct 24 '22 07:10

Andrea Thacker