Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.os.Environment;

public class Main {
    /**
     * Get the corresponding file of the dcimDirectory /sdcard/DCIM/name. Will
     * create the dcimDirectory if is doesn't exist.
     * 
     * @param dirName
     *            the dcimDirectory dirName.
     * @return the dcimDirectory's corresponding file.
     */
    public static File getDcimDirectory(String dirName) {
        if (dirName == null) {
            return null;
        }

        File dcimDirectory = null;
        String dcimPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getPath();
        dcimDirectory = new File(dcimPath, dirName);
        if (!dcimDirectory.exists()) {
            dcimDirectory.mkdirs();
        }

        return dcimDirectory;
    }
}