Java tutorial
//package com.java2s; import android.content.Context; import android.os.Environment; import java.io.File; public class Main { public static final String ImgFolderName = "UDeskIMg"; public static File getOutputMediaFile(Context context, String mediaName) { File mediaStorageDir = null; try { // mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), ImgFolderName); mediaStorageDir = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), ImgFolderName); } catch (Exception e) { e.printStackTrace(); } if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { return null; } } File mediaFile = new File(mediaStorageDir.getPath() + File.separator + mediaName); return mediaFile; } }