Is there an universal way to find the location of an external SD card?
Please, do not be confused with External Storage.
Environment.getExternalStorage
Here is the way I use to find the external card. Use mount cmd return then parse the vfat part.
String s = "";
try {
Process process = new ProcessBuilder().command("mount")
.redirectErrorStream(true).start();
process.waitFor();
InputStream is = process.getInputStream();
byte[] buffer = new byte[1024];
while (is.read(buffer) != -1) {
s = s + new String(buffer);
}
is.close();
} catch (Exception e) {
e.printStackTrace();
}
//用行分隔mount列表
String[] lines = s.split("\n");
for(int i=0; i