Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import android.annotation.TargetApi; import android.os.Build; import android.util.Log; public class Main { public static Context applicationContext; /** * Get a list of external SD card paths. (Kitkat or higher.) * * @return A list of external SD card paths. */ @TargetApi(Build.VERSION_CODES.KITKAT) private static String[] getExtSdCardPaths() { List<String> paths = new ArrayList<>(); for (File file : applicationContext.getExternalFilesDirs("external")) { if (file != null && !file.equals(applicationContext.getExternalFilesDir("external"))) { int index = file.getAbsolutePath().lastIndexOf("/Android/data"); if (index < 0) { Log.w("Uri", "Unexpected external file dir: " + file.getAbsolutePath()); } else { String path = file.getAbsolutePath().substring(0, index); try { path = new File(path).getCanonicalPath(); } catch (IOException e) { // Keep non-canonical path. } paths.add(path); } } } return paths.toArray(new String[paths.size()]); } }