private static String getDefaultPath(){
boolean
isHaveExternalSD = false;
String DefaultPath =
"/storage/sdcard0";
File externalSDCard = new
File("/storage/sdcard1");
try {
IMountService ms = getMs();
isHaveExternalSD =
ms.getVolumeState("/storage/sdcard1").equals(Environment.MEDIA_MOUNTED);
} catch (Exception e) {
// TODO: handle
exception
e.printStackTrace();
}
if(isHaveExternalSD){
DefaultPath = externalSDCard.toString();
System.out.println("wangdandan1"+DefaultPath);
}
System.out.println("wangdandan"+DefaultPath);
return
DefaultPath;
}
private static
IMountService getMs() {
// TODO
Auto-generated method stub
IBinder
service = ServiceManager.getService("mount");
if (service != null) {
return
IMountService.Stub.asInterface(service);
} else {
System.out.println("Can‘t get mount service");
}
return
null;
}
原文地址:http://www.cnblogs.com/plpdan/p/3716781.html