Android File Delete deleteDirContent(File d)

Here you can find the source of deleteDirContent(File d)

Description

delete Dir Content

Declaration

public static void deleteDirContent(File d) 

Method Source Code

//package com.java2s;
import java.io.File;

public class Main {
    public static void deleteDirContent(File d) {
        if (!d.exists())
            return;
        if (!d.isDirectory())
            return;
        File[] children = d.listFiles();
        for (File c : children) {
            if (c.isDirectory())
                deleteDirContent(c);/*w ww .j  a  v a 2 s  .  com*/
            else
                deleteFile(c);
        }
    }

    public static void deleteFile(File f) {
        if (!f.exists())
            return;
        boolean deleted = f.delete();
        if (!deleted)
            throw new IllegalStateException("Could not delete file " + f);
    }
}

Related

  1. deleteApkInSystem(String fileName, int type)
  2. deleteDatabaseFile(int type, Context context)
  3. deleteDir(File dir)
  4. deleteDir(File dir)
  5. deleteDir(File spec)
  6. deleteFile(File f)
  7. deleteFile(File f)
  8. deleteFile(File f)
  9. deleteFile(File file)