简体   繁体   中英

Completely uninstall and reinstall Android app on update?

I want to publish a new version of my app. But I want it to reinstall again.

Like first uninstall and then install(like first time installation). Is there anyway that I can do it? Or force users to first uninstall the app?

If you sign the new apk with a different key, users will hit an error when they try to upgrade an existing installation. That's probably the easiest way to do it without changing the package name.

As Jens said you can't do this really unless you reinstall with a different package name (not a good idea either.) You have to detect your version and manually reset your preferences etc. if you need to. This is a pretty annoying feature of android. I've been developing a mapping application that has the exact same problem with storing some of the background data.

You can usually check where your preferences get created for the first time. A lot of people do a if(preference !=null) to set them up, since in a pre-installed app you already have that preference in the bundle it will not update or generate a new one.

Try setting the preference checker to be if(preference != newValueOfPreference)

If that's not how your bundle data is generated on install you'll have to find out how it is generated and get at that hook.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM