Question

I followed this guide for download expansion files. When I checked it, the download worked fine, but when I wanted to uninstall the application from the phone the files stayed there.
How can I cause the files to be deleted with the app?

Was it helpful?

Solution

Downloaded expansion file(s) will be stored in your shared-storage folder (usually this is your sd-card). There is no code that can be triggered when uninstalling your application. This unfortunately means that you cannot remove expansion files from code when uninstalling the application.

However I did find out that on my Nexus 4 but also on a Samsung Galaxy S the expansion file is automatically deleted from the shared-storage folder when uninstalling the application. I tested this using an application that is in the play store.

When the expansion file is not deleted automatically then the only way to get rid of your expansion files after an uninstall would be to manually delete the file(s) from your shared-storage folder. An end-user can be instructed to remove the expansion file manually by letting him/her attach the device to the computer and navigate to:

<shared-storage>/Android/obb

In this folder you should see one or more folders with package names. Pick the folder that will contain your expansion file and delete the package folder or the expansion file depending on what you wish to be deleted. Be aware that deleting the wrong package can affect different apps. So use manual deletion with caution!

Some reasons why an expansion can't be deleted by end-user:

  • End-user doesn't have drivers for the device so it can't see what's on the shared-storage
  • End-user uninstalled the application and the expansion file is already gone

OTHER TIPS

Store your app files in the Applications private directory.

This can be obtained with getFilesDir()

When your application is uninstalled, all files in this directory get deleted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top