我想格式化 SD 卡,我正在使用以下代码。但是SD卡不能挂载。
public boolean formatSD() {
boolean bool = false;
IMountService mountService = null;
try{
IBinder ibi = ServiceManager.getService("mount");
if(ibi!=null) {
mountService = IMountService.Stub.asInterface(ibi);
String extern_sd = Environment.getFlashStroageDirectory().getAbsolutePath();
mountService.unmountVolume(extern_sd, true);
Thread.sleep(4000);
int result_format = mountService.formatVolume(extern_sd);
System.out.println("result_format: "+result_format);
if(result_format==0){
Thread.sleep(4000);
int result_mount = mountService.mountVolume(extern_sd);
System.out.println("result_mount: "+ result_mount);
}
bool = true;
}
}catch(Exception e){
System.out.println("Exception format: "+e.getMessage());
}
return bool;
}
有人可以告诉我我做错了什么吗?谢谢