get Photo Directory - Android Camera

Android examples for Camera:Photo

Description

get Photo Directory

Demo Code


//package com.java2s;

import android.os.Environment;
import android.util.Log;
import java.io.File;

public class Main {
    public static File getPhotoDirectory() {
        File outputDir = null;/*from w w w  .ja  v a 2 s.  c o m*/
        String externalStorageState = Environment.getExternalStorageState();

        if (externalStorageState.equals(Environment.MEDIA_MOUNTED)) {
            File picturesDir = Environment
                    .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
            outputDir = new File(picturesDir, "asdf");

            if (!outputDir.exists()) {
                if (!outputDir.mkdirs()) {
                    Log.e("CAMERA_HELPER",
                            "Unable to create output directory");
                    outputDir = null;
                }
            }
        }
        return outputDir;
    }
}

Related Tutorials