views:

84

answers:

1

I tested that it is possible for Android to pass newVersion < oldVersion to SQLiteOpenHelper.onUpgrade() method, ie. it wants the application to downgrade its database.

I don't want to handle this case, though I would like to notify the user somehow that there exists a newer version of my application (which she apparently had installed previously) and that's the one she should be using.

Any ideas what would be the best way to achieve this? Toast? AlertDialog (but in what context)?

+1  A: 

Indeed, you can call that method with a "new" version smaller than the "old" version, but when would it ever happen?

Unless you expect your users to manually reinstall your app, overwriting it with an earlier APK, there's no need to think about this.

Christopher
Imagine this scenario. You're a power user, using my app and enjoying it. Then I'm releasing a new version which you install but don't like (eg. you think it has grown too much and become a bloatware), so you decide to manually install the apk of the old version. If I do nothing inside onUpgrade() to handle this case, user data may get corrupted or I can throw RuntimeException to prevent the app from running. Neither solution looks good to me. I know this would be a rather rare case but I would like to know the answer nevertheless :]
Immortal
Seems like a reasonable situation to me, however I'm not sure why you're liable for application errors in that situation - it's by far a non-standard usage scenario. I would think that a power user might expect that they'd have to do a clean install to downgrade.
Daniel Lew
Daniel, I guess you're right. It's not that important to bother. I think I'll just throw RuntimeException in that case. Thanks for convincing me ;]
Immortal
Usually we simply erase the current incompatible database when in a situation like this.
hackbod