First make sure that the shell command you need is really available in Android. I ran into problems suggesting that you can do things like redirecting output with .
This method also works on undisturbed phones, I believe v2.2, but you should definitely check the API link.
try { Process chmod = Runtime.getRuntime().exec("/system/bin/chmod 777 " +fileName); BufferedReader reader = new BufferedReader( new InputStreamReader(nfiq.getInputStream())); int read; char[] buffer = new char[4096]; StringBuffer output = new StringBuffer(); while ((read = reader.read(buffer)) > 0) { output.append(buffer, 0, read); } reader.close(); chmod.waitFor(); outputString = output.toString(); } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); }
While this is probably not 100% necessary, it is a good idea for the process to wait for exec to complete with process.waitFor (), as you said you take care of the exit.
source share