Reputation: 5295
I have downloaded my app from app store and run it from the apk file. Now ,i want a check or something that if the app is already installed and if i try to install it again from the apk, the already installed app should un-install first then install it again.
Basically the scenario is, i have stored some things in sqllite db and when i install app again, the currently installed app does get un-installed but the db is not deleted. So the db gets overridden.
So can i achieve this via code or something ?
Upvotes: 0
Views: 435
Reputation: 2877
Just update version code and version name in your manifest and run the app,it will updated your app and Db too.It will update the application by removing the older version, and installing the new one.
Upvotes: 0
Reputation: 15775
The system will prevent you from installing over an existing package, especially if it is the same version as the existing installation. You'd have to use adb or the app management to manually uninstall an app before installing it again.
Upvotes: 0
Reputation: 10621
I think this is not possible. The purpose of the update mechanism is that old data will be kept. But you can add a check to your code that deletes the old sqlite db first after an update, simply check if the file exists and save that result for later to prevent deleting on every start.
Upvotes: 1
Reputation: 640
If you use the exact same APK
key, and increase your version in the `Manifest
file, it should reinstall the application by removing the older version, and installing the new one.
Upvotes: 0
Reputation: 8702
You must increase the version number in your Manifest
and sign the APK
with the exact same key.
Upvotes: 0
Reputation: 33
if you are test application on device..then go to Setting->Apps->Click on your application it show uninstall button click on that.your application is remove.then copy new apk file and install.
Upvotes: 0