I need to clear(equivalent to Clear Data in App Settings) all the old data in the app programmatically when the user updates the app from Google Play Store or any other sources. This is because I don't need any of the existing data from the old app since I have changed everything in the new app compared to the old one.
I thought of implementing a version check at the app startup, but I can't find a way to get the app's previous versionCode
or versionName
. The only way I figured out to clear the data is to check the lastUpdateTime
at the time of publishing the app. But it's not reliable since the user has other ways or sources of getting the app (like sharing it with a friend or if the user had a backup of the old app).
Any Suggestions?