I'm trying to unmount and mount USB devices programmatically. I can do it in adb with these commands:
umount /mnt/usb1
mount -t vfat -o rw /dev/block/sdb /mnt/usb1
But when I try to execute these commands from my app it doesn't work. Here is the codes I use:
Process proc = Runtime.getRuntime().exec(
new String[] { "/system/xbin/su", "-c",
"umount /mnt/usb1" });
proc.waitFor();
Process pr = Runtime.getRuntime().exec(new String[] {
"/system/xbin/su", "-c",
"mount -t vfat -o rw /dev/block/sdb /mnt/usb1" });
pr.waitFor();
Description of exec() method says: "Executes the specified command and its arguments in a separate native process. " So I think that command works but in a different process. In the process which my app runs, nothing gets effected. So I want to execute these commands in the process that my app runs.
I can get the process ID, thanks to this question . Is there a way to use this process ID to call current process and execute shell commands?