How Can I Run Some Code When The User Updates My App?
Solution 1:
You should use a SQLiteOpenHelper-class to manage your Database (tutorial).
In your new App's version, you simple increase the version-number of the Database so the onUpgrade()
-method gets called and you do your work on the Database.
Solution 2:
I'd do the transformation the first time your code is run after the update: there's no need to do it any earlier.
And then I'd take the usual approach to this: once you've done the update, write some field to the database that indicates the current version. And when that field equals the current version then you know that no update needs to be done.
Solution 3:
Well, if it's only the database you want to change take a look at SQLiteDatabase.onUpgrade. For more information look at IE http://www.barebonescoder.com/2010/05/android-development-database-management/
If it's not just the database I would use Preferences to keep a reference on which version the user has and if the user has run the latest update routine.
Post a Comment for "How Can I Run Some Code When The User Updates My App?"