views:

451

answers:

1

It'd be convenient if an application I'm writing stored some files to external storage permanently (so they persist after the application has been exited[destroyed]), but on an uninstall I'd like to do the decent thing and have these files removed to free up the storage.

Is there any way I can have these files removed on an uninstall?

If there isn't (and I'm skeptical), then I'll have to create these files each time. I'm trying to save start-up time and also occupy required space by having them exist permanently.

Note: I need to use external storage, so both internal storage or a DB would be inappropriate.

+3  A: 

No, I don't believe so. Only files that you write to internal storage will be removed when your application is uninstalled (or if the user presses the 'clear data' button in the Application settings app).

Your app can't receive its own PACKAGE_REMOVED broadcast intent either, so you essentially have no notification that you're being uninstalled.

Christopher
Just to clarify, you can't create a broadcast receiver as part of your app that listens for this?
Ally
You can create a broadcast receiver that listens for any `PACKAGE_*` events the system sends, but you won't receive them for your own application *except* for when your application is being upgraded -- you'll get `PACKAGE_REMOVED` followed soon after by `PACKAGE_REPLACED`.
Christopher