I have an App that write some file in the SD Card used to store data object. When the user delete the app or the app is updated, these files remains in the SD and aren’t removed with apk. This could lead to some annoying issue if I change the data management structure of my App, really difficult to fix simply checking if these dat file are already present for various reason.
Is there a way to say to Android OS to remove also these files when the app is unistalled or updated without manual intervention of the user?
For the update case, yes. Implement a
BroadcastReceiversubclass…… and then add a
<receiver>tag to your manifest:There is also a
PACKAGE_REMOVEDaction, but theIntentwith that action fires after apps are removed, so you don’t have a chance to clean up.