/**
* 获取内置SD卡路径
* 内置SD卡路径:/storage/emulated/0
* @return
*/
public String getInnerSDCardPath() {
return Environment.getExternalStorageDirectory().getPath();
}
/**
* 获取外置SD卡路径
* 外置SD卡路径:/storage/extSdCard
* @return 应该就一条记录或空
*/
public List<string> getExtSDCardPath()
{
List<string> lResult = new ArrayList<string>();
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("mount");
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
if (line.contains("extSdCard"))
{
String [] arr = line.split(" ");
String path = arr[1];
File file = new File(path);
if (file.isDirectory())
{
lResult.add(path);
}
}
}
isr.close();
} catch (Exception e) {
}
return lResult;
}
//获取外置SD卡路径
List<string> extPaths = getExtSDCardPath();
for (String path : extPaths) {
log.append("外置SD卡路径:" + path + "\r\n");
}
System.out.println(log.toString());