get Album Directory - Android android.media

Android examples for android.media:Album

Description

get Album Directory

Demo Code

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

public class Main{

    public static File getAlbumDir() {
        File storageDir = null;/*from   w ww.j  a  va  2 s.c  om*/
        if (Environment.MEDIA_MOUNTED.equals(Environment
                .getExternalStorageState())) {
            storageDir = getAlbumStorageDir();
            if (storageDir != null) {
                if (!storageDir.mkdirs()) {
                    if (!storageDir.exists()) {
                        Log.d("CameraSample", "failed to create directory");
                        return null;
                    }
                }
            }
        } else {
            Log.v("",
                    "External storage is not mounted READ/WRITE.");
        }
        return storageDir;
    }
    public static File getAlbumStorageDir() {
        return new File(
                Environment
                        .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                "ALBUM_NAME");
    }

}

Related Tutorials