How do I most easily delete Android application data upon upgrade/update?

后端 未结 1 1968
忘掉有多难
忘掉有多难 2020-12-20 23:03

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, an

相关标签:
1条回答
  • 2020-12-20 23:38

    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").

    0 讨论(0)
提交回复
热议问题