When my android app is removed, I would like to also remove files the app has created on the SD card, as these can consume many megabytes and are only of use to my app.
The documentation says:
The package that is being removed does not receive this Intent.
Android 2.2 added getExternalFilesDir()
, which will point to a place on the external storage that Android will automatically clean up when your application is uninstalled. However, that is only for Android 2.2, and there are indications that it does not work particularly well at the moment. However, it is something to keep in mind for 2011.
Beyond that, all you can really do is offer a menu choice somewhere for the user to do the cleanup, and hope users use it before uninstalling you.
You must add the permission in the manifast.
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />