Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.util.Log;

import java.io.File;

public class Main {

    public static void deleteFilesByDirectory(File directory) {
        //       LogUtil.e("TAG", "deleteFiles--directory:"+directory);
        //       LogUtil.e("TAG", "deleteFiles--exists:"+directory.exists());
        //       LogUtil.e("TAG", "deleteFiles--isDirectory:"+directory.isDirectory());
        if (directory != null && directory.exists() && directory.isDirectory()) {
            for (File item : directory.listFiles()) {
                Log.e("TAG", "deleteFiles--item:" + item);
                Log.e("TAG", "deleteFiles--item.isdir:" + item.isDirectory());
                if (item != null && item.isDirectory()) {
                    for (File itemsec : item.listFiles()) {
                        itemsec.delete();
                    }
                }
                item.delete();
            }
        }
    }
}