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.os.Environment;
import java.io.File;

public class Main {
    private static String createDir(String path) {
        boolean isHaveSDCard = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
        if (!isHaveSDCard) {
            return null;
        }
        File directory = Environment.getExternalStorageDirectory();
        File file = new File(directory.getAbsolutePath() + path);
        if (!file.exists()) {
            boolean isSuccess = file.mkdirs();
            if (isSuccess) {
                return file.getPath() + File.separator;
            } else {
                return null;
            }
        }
        return file.getPath() + File.separator;
    }
}