Is there an universal way to find the location of an external SD card?
Please, do not be confused with External Storage.
Environment.getExternalStorage
Since my original answer above, scanning vold is no longer viable across the various manufacturers.
I've developed a more reliable and straight forward method.
File mnt = new File("/storage");
if (!mnt.exists())
mnt = new File("/mnt");
File[] roots = mnt.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && pathname.exists()
&& pathname.canWrite() && !pathname.isHidden()
&& !isSymlink(pathname);
}
});
roots will contain all the writeable root directories on the system, including any usb connected usb devices.
NOTE: The canWrite method needs the android.permission.WRITE_EXTERNAL_STORAGE permission.