0

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

4

1 回答 1

0

这不仅会列出已挂载的 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);
}
于 2012-11-28T15:19:23.163 回答