tags:

views:

464

answers:

2

My application use the SDCard to store data (about 100 Mb of stuff). I would like to delete these file when the application is deleted through the application manager and offer a way to clear the data from there (like the Google Apps does). Any ideas ?

A: 

This is not possible -- sorry. The best you can do is have a "cleanup" menu choice that wipes out this data, that a user can use before uninstalling you.

CommonsWare
Ok, I have already done that. That's kinda sad since I didn't want to leave crap on the user sd card. Any idea why Google apps can have this option ? Thanks
Jean-Philippe Jodoin
I believe this is an anti-malware tactic, much like how they do not automatically start applications when they are installed. That being said, it would be nice if there were at least a place where you could register directories for Android to clean up on uninstall.
CommonsWare
+1  A: 

Quote From http://developer.android.com/guide/topics/data/data-storage.html

Accessing files on external storage

If you're using API Level 8 or greater, use getExternalFilesDir() to open a File that represents the external storage directory where you should save your files. ... If the user uninstalls your application, this directory and all its contents will be deleted.

From my understanding this will create a file on the sd card which has a scope (like a directory of your applications package namespace) and the phone will delete the directory when you uninstall the app. I assume this is how Google apps achieves this function.

Akusete
Thanks, I'll try that.
Jean-Philippe Jodoin