I am trying to unmount the sdcard/usb drive programatically from Android JellyBean device. I have the mountpaths for them. /mnt/udisk and /mnt/extsd respectively. I have SuperUser Access. I have tried running the following code but does not give me the results:
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();
}