Ive been looking for this code for sometime.
Deletes all files in a directory recursively.
void delete(File f) throws IOException {
if (f.isDirectory()) {
File[] file = f.listFiles();
if(file != null)
for (File c : file)
delete(c);
}
if (!f.delete())
{
Log.e(TAG, "Failed to delete file: " + f);
}
else
{
Log.i(TAG, "Deleted file: " + f);
deleted++;
}
}
If you want to delete Sd Card in Android,
File extStore = Environment.getExternalStorageDirectory();
call delete(extStore)
EnjoY!
No comments:
Post a Comment