Java tutorial
//package com.java2s; import android.os.Environment; import java.io.File; public class Main { public static File getExternalStorageDir(String dir) { File result = new File(Environment.getExternalStorageDirectory(), dir); if (!isExternalStorageWritable()) { return null; } if (!result.exists() && !result.mkdirs()) { return null; } return result; } public static boolean isExternalStorageWritable() { // get the external storage condition String state = Environment.getExternalStorageState(); // if writable if (Environment.MEDIA_MOUNTED.equals(state)) { return true; } return false; } }