Android examples for android.os:Environment
get External Storage Directory
import java.io.File; import android.os.Environment; public class Main { public static File getExternalStorageDirectory() { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { return Environment.getExternalStorageDirectory(); } else if ((new File("/mnt/sdcard2")).exists()) { return new File("/mnt/sdcard2"); } else if ((new File("/mnt/sdcard0")).exists()) { return new File("/mnt/sdcard0"); } else {/*from w ww . j a va 2s . co m*/ return null; } } }