Search code examples
androidbackupuninstallationandroid-lifecycleandroid-backup-service

Android - Preserve or delete files created by the application on uninstall


I created an application which creates and stores files to sdcard. Is there a way to bind the folder with application in order to delete all files when the user runs uninstall on android device?


Solution

  • There's no way for your application to know that it is being uninstalled (without modifying the kernel). All files created in the data/data/your.app.package is deleted automatically upon application uninstall.

    I don't think anything is cleared from the sdcard. You can do a quick test and find that out.

    Another approach could be to have another application that checks whether this application is installed or not. If not, it can do the clean-up work.