Created
May 9, 2017 02:23
-
-
Save kevalpatel2106/ec70894cfd7b6419af17bf0c882b119e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Here is the mount drive function which I called in onCreate of my activity. | |
private void mountDrive() throws IOException, InterruptedException { | |
Process mProcess = Runtime.getRuntime().exec("/system/xbin/su"); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(mProcess.getInputStream())); | |
DataOutputStream dos = new DataOutputStream(mProcess.getOutputStream()); | |
dos.writeBytes("mkdir /mnt/usb\n"); | |
dos.flush(); | |
dos.writeBytes("mount -t vfat -o rw /dev/block/sda1 /mnt/usb\n"); | |
dos.flush(); | |
dos.writeBytes("exit\n"); | |
//Read the response | |
String line, result = ""; | |
while ((line = reader.readLine()) != null) { | |
result += line; | |
Log.d("CMD","RESULT:"+result); | |
} | |
reader.close(); | |
dos.flush(); | |
dos.close(); | |
mProcess.waitFor(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment