Java tutorial
//package com.java2s; import android.os.Environment; import java.io.File; public class Main { public static File getDestinationInExternalPublicDir(String dirType, String fileName) { File file = Environment.getExternalStoragePublicDirectory(dirType); if (file.exists()) { if (!file.isDirectory()) { throw new IllegalStateException(file.getAbsolutePath() + " already exists and is not a directory"); } } else { if (!file.mkdirs()) { throw new IllegalStateException("Unable to create directory: " + file.getAbsolutePath()); } } //mDestinationUri = Uri.withAppendedPath(Uri.fromFile(file), subPath); /*File destFolder = new File(file.getAbsolutePath() + File.separator + DOWNLOAD_FOLDER); if (destFolder.exists()) { if (!destFolder.isDirectory()) { throw new IllegalStateException(file.getAbsolutePath() + " already exists and is not a directory"); } } else { if (!destFolder.mkdirs()) { throw new IllegalStateException("Unable to create directory: "+ destFolder.getAbsolutePath()); } } File destFile = new File(destFolder.getAbsolutePath() + File.separator + fileName);*/ return new File(file.getAbsolutePath() + File.separator + fileName); } }