Reputation: 2024
I would like to upgrade my app to android market and some users have the old version of the app. What I want to do is in my new app, I want to run some codes to change a bit on the app database when the user do the update of my app, so how can I check if the user has the older version of my app in their mobile?
Upvotes: 0
Views: 387
Reputation: 8225
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.
Upvotes: 0
Reputation: 25755
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.
Upvotes: 4
Reputation: 308061
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.
Upvotes: 1