get External Storage Directory - Android android.os

Android examples for android.os:Environment

Description

get External Storage Directory

Demo Code

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;
    }
  }
}

Related Tutorials