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

voiddeleteFile(File file)
delete File
if (file.exists()) {
    if (file.isFile()) {
        file.delete();
    } else {
        File[] files = file.listFiles();
        if (files != null) {
            for (File f : files) {
                deleteFile(f);
...
voiddeleteFile(String filePath)
delete File
if (filePath != null) {
    File file = new File(filePath);
    deleteFile(file);
voiddelete(File file)
delete
if (file.exists()) {
    if (file.isFile()) {
        file.delete();
    } else {
        File[] files = file.listFiles();
        for (File f : files) {
            delete(f);
        file.delete();
booleandeleteFile(String fileName)
delete File
try {
    File directory = new File(fileName);
    return directory.delete();
} catch (Throwable e) {
    return false;
booleanDeleteFile(File file)
Delete File
if (file.isFile()) {
    return file.delete();
if (file.isDirectory()) {
    File[] childFile = file.listFiles();
    if (childFile == null || childFile.length == 0) {
        return file.delete();
    for (File f : childFile) {
        DeleteFile(f);
    return file.delete();
return false;