get Dcim Directory from Environment - Android Hardware

Android examples for Hardware:Directory

Description

get Dcim Directory from Environment

Demo Code


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

import android.os.Environment;

public class Main {

    public static File getDcimDirectory(String dirName) {
        if (dirName == null) {
            return null;
        }//from  ww  w  . j a va2 s . com
        File dcimDirectory = null;
        String dcimPath = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_DCIM).getPath();
        dcimDirectory = new File(dcimPath, dirName);
        if (!dcimDirectory.exists()) {
            dcimDirectory.mkdirs();
        }
        return dcimDirectory;
    }
}

Related Tutorials