Jean-Philippe Jodoin
Jean-Philippe Jodoin

Reputation: 4736

Android - Remove data from SDCard

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 ?

Upvotes: 0

Views: 3569

Answers (1)

Akusete
Akusete

Reputation: 10794

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.

Upvotes: 7

Related Questions