tags:

views:

31

answers:

1

So, I have found a bug in a specific sdk that causes it to fail on some Android phones after re-installing a new version of an app which uses the sdk (via adb install -r, and presumably when a user gets an update that has been pushed to the Android market). Is there any way to force an application's data to automatically be cleared upon update of the app? I realize there are different ways that data could be stored, but I just need to essentially simulate an invocation of the "Clear Data" button that'd you find when browsing to the application in the "Manage Applications" section of the Settings (i.e. I just want all data gone).

I am an Android noob and am doing minimal Java coding on this project, so I am basically looking for the simplest solution here. I suppose I could settle on storing a "currentVersion" to disk and then checking it upon launch every time to see if the real current version matches the version that was written to disk on the last launch. Is that the only real way to do this? If so, what's the simplest way to do so?

Thanks!

+1  A: 

Is there any way to force an application's data to automatically be cleared upon update of the app?

No, at least for my definition of "automatic".

I suppose I could settle on storing a "currentVersion" to disk and then checking it upon launch every time to see if the real current version matches the version that was written to disk on the last launch. Is that the only real way to do this?

I'd name it lastKnownVersion, but otherwise this approach seems sound and probably is your only viable option.

If so, what's the simplest way to do so?

Ummm...do exactly what you said. Use Java I/O (storing the file somewhere inside of getFilesDir()), or SharedPreferences.

Bear in mind, though, that your users may get rather frustrated if you blow away their data on an app update. Personally, I'd rather we find a better solution to your original problem ("I have found a bug in a specific sdk that causes it to fail on some Android phones after re-installing a new version of an app which uses the sdk").

CommonsWare
I agree. But this would only happen in the free version of my app, since the sdk I am referring to is actually the provider of ads. Thus, I cannot really afford to just give the app away and have them not correctly see ads, so my only other alternative would be to force them to uninstall and reinstall the app, which seems like a terrible idea.
rrbrambley