public void RunCmd(String mycmd) { Process su = null; try { su = Runtime.getRuntime().exec("su"); } catch (IOException e) { e.printStackTrace(); } DataOutputStream outputStream = new DataOutputStream(su.getOutputStream()); try { outputStream.writeBytes(mycmd+"\n"); outputStream.flush(); outputStream.writeBytes("exit\n"); outputStream.flush(); try { su.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } }