Can I delete SD card data specific to an application while uninstalling the application programmatically?
Asked
Active
Viewed 363 times
0
-
1http://stackoverflow.com/questions/6574277/android-delete-files-on-sd-card-on-uninstall – Ram kiran Pachigolla Aug 23 '12 at 05:32
1 Answers
0
Use this
@Override
protected void onDestroy()
{
super.onDestroy();
File checkFile = new File("/sdcard/Accentra/");//getting the control of sdcard files
deleteDir(checkFile);
}
//Deleting the temperary folder and the file created in the sdcard
public static boolean deleteDir(File dir)
{
if (dir.isDirectory())
{
String[] children = dir.list();
for (int i=0; i<children.length; i++)
{
boolean success = deleteDir(new File(dir, children[i]));
if (!success)
{
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}

Manoj Kumar
- 1,510
- 3
- 20
- 40
-
I do have several activities in my application, I which activity i have to write the onDestroy() method? – Richa Laad Aug 23 '12 at 06:13