Take the 2-minute tour ×

Is it possible to have a code that detect if my app has been uninstalled and upon uninstalling, all the relevant folders that my app has created will be deleted automatically?


share|improve this question
These guys managed to do it: play.google.com/store/apps/details?id=com.UCMobile.intl –  zwebie Mar 25 at 12:04
That's technically a correct answer (even though I didn't see where they say they managed to do that on the link you provided), but the followup question is: how did they do that? –  DelGurth Aug 6 at 10:53

4 Answers 4

Regarding being able to detect the Uninstallation, I'm afraid its not possible.

Whenever an application package is removed(App is Uninstalled), ACTION_PACKAGE_REMOVED intent will be sent out to all receivers EXCEPT for your own.

From the docs:-

Broadcast Action: An existing application package has been removed from the device. The data contains the name of the package. The package that is being installed does not receive this Intent.

This is confirmed here.

share|improve this answer
sadly this is true :( i wish this was possible –  Rauf Sep 26 '13 at 9:38

No dear you cant check that your application is going to uninstall.

But you can create your folder in your cache dir so that when your application will be deleted all folders and files automatically will be deleted.

Please check it. http://developer.android.com/guide/topics/data/data-storage.html

share|improve this answer
up vote 0 down vote accepted

Thanks for all your solutions! At least I know now my app cannot detect an uninstall.
But I have solved the problem of removing all the relevant folders that my app has created by placing relevant folders in: context.getExternalFilesDir(null).getAbsolutePath()
Everytime Android uninstall ur app, it will delete everything in the /mnt/sdcard/Android/data/com.yourapp.com folder.
context.getExternalFilesDir(null).getAbsolutePath(); put ur folders inside the /mnt/sdcard/Android/data/com.yourapp.com folder.

share|improve this answer

You can detect whether app is uninstalled but cannot remove folders on uninstallation as when we get app uninstalled broadcast by that time the application is already un-installed. The only way u can use this broadcast is create another application (say application 2) that will receive broadcast for un-installation of application 1 and there you can delete those folders.

share|improve this answer

Your Answer


