我正在尝试从Android JellyBean设备以编程方式卸载sdcard / usb驱动器。我有他们的mountpaths。分别是/ mnt / udisk和/ mnt / extsd。我有SuperUser Access。 我试过运行以下代码,但没有给我结果:
Process su = null;
try {
su = Runtime.getRuntime().exec("su");
String cmd = "umount /mnt/extsd/"+ "\n";
su.getOutputStream().write(cmd.getBytes());
String exit = "exit\n";
su.getOutputStream().write(exit.getBytes());
su.waitFor();
Toast.makeText(MyAndroidAppActivity.this, "Completed", Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(MyAndroidAppActivity.this, e.toString(), Toast.LENGTH_LONG).show();
} finally {
if (su != null) {
su.destroy();
}