Android Utililty Methods File Delete

List of utility methods to do File Delete

Description

The list of methods to do File Delete are organized into topic(s).

Method

booleandeleteFile(File file)
delete File
if (file != null && file.exists()) {
    if (file.isFile()) {
        return file.delete();
    } else {
        for (File f : file.listFiles()) {
            deleteFile(f);
        return file.delete();
...
booleandeleteFile(File root)
delete File
if (root.exists()) {
    if (root.isDirectory()) {
        File[] files = root.listFiles();
        for (int i = 0; i < files.length; i++)
            deleteFile(files[i]);
    return root.delete();
return false;
booleandeleteFile(File spec)
Deletes a file or directory.
return deleteDir(spec);
voiddeleteFile(String filePath)
delete File
if (StringUtil.isEmpty(filePath)) {
    return;
File file = new File(filePath);
if (!file.exists()) {
    return;
if (file.isDirectory()) {
...
voiddeleteFile(String filePath)
delete File
File file = new File(filePath);
deleteFile(file);
booleandeleteFile(String filename)
delete File
File file = new File(filename);
if (file.isFile()) {
    return file.delete();
return false;
voiddeleteFile(String path)
Convenience function to delete a file.
if (!new File(path).delete())
    throw new IOException(String.format(
            "Unable to delete file '%s'", path));
voiddeleteFile(String path)
delete File
File file = new File(path);
if (!file.exists() || file.isFile())
    return;
if (file.isDirectory())
    deleteSubfiles(file.getAbsolutePath());
file.delete();
booleandeleteFile(String path)
Deletes a file or directory.
return deleteDir(new File(path));
voiddeleteFile(String path)
delete File
File file = new File(path);
deleteFile(file);