枚举安装在安卓手机上的SD卡



如何从Java或本机代码枚举安装在Android手机上的所有SD卡?

这不仅会列出挂载的SD卡,还会列出Android设备上所有挂载的文件系统。

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cat /proc/mounts");
BufferedReader stdInput = new BufferedReader(new 
     InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new 
     InputStreamReader(proc.getErrorStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null) {
    System.out.println(s);
}

最新更新