Java tutorial
//package com.java2s; //License from project: Apache License import android.os.Environment; import java.io.File; public class Main { public static final String PHOTO_FOLDER = "/VICLEEPHOTO"; public static String getPhotoSavePath() { String dcimDir = null; File extDcimDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); if (extDcimDir == null || !extDcimDir.exists()) { File extDir = Environment.getExternalStorageDirectory(); if (extDir == null) { return null; } dcimDir = extDir.getAbsolutePath() + "/DCIM"; try { new File(dcimDir).mkdirs(); } catch (Exception e) { } } else { dcimDir = extDcimDir.getAbsolutePath(); } return dcimDir + PHOTO_FOLDER; } public static String getPhotoSavePath(String dir) { String dcimDir = null; File extDcimDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); if (extDcimDir == null || !extDcimDir.exists()) { File extDir = Environment.getExternalStorageDirectory(); if (extDir == null) { return null; } dcimDir = extDir.getAbsolutePath() + "/DCIM"; try { new File(dcimDir).mkdirs(); } catch (Exception e) { } } else { dcimDir = extDcimDir.getAbsolutePath(); } if (dir == null) { return dcimDir + PHOTO_FOLDER; } else { return dcimDir + "/" + dir; } } }