Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Environment;

import java.io.File;

public class Main {
    public static String workingDirectory = Environment.getExternalStorageDirectory().getAbsolutePath()
            + "/BSDImage";

    public static void deleteContentWorkingDirectory() {
        deleteDirectoryContent(workingDirectory);
    }

    private static void deleteDirectoryContent(String directoryPath) {
        File dir = new File(directoryPath);
        if (dir.exists() && dir.isDirectory()) {
            String[] children = dir.list();
            for (int i = 0; i < children.length; i++) {
                File file = new File(dir, children[i]);
                if (file.isDirectory()) {
                    deleteDirectoryContent(file.getAbsolutePath());
                } else {
                    file.delete();
                }
            }
            dir.delete();
        }
    }
}