upgrade Root Permission - Android android.app

Android examples for android.app:Permission

Description

upgrade Root Permission

Demo Code

import java.io.DataOutputStream;

public class Main {

  public static boolean upgradeRootPermission(String pkgCodePath) {
    Process process = null;/*from  www . ja v  a2  s .c  o  m*/
    DataOutputStream os = null;
    try {
      String cmd = "chmod 777 " + pkgCodePath;
      process = Runtime.getRuntime().exec("su"); 
      os = new DataOutputStream(process.getOutputStream());
      os.writeBytes(cmd + "\n");
      os.writeBytes("exit\n");
      os.flush();
      process.waitFor();
    } catch (Exception e) {
      return false;
    } finally {
      try {
        if (os != null) {
          os.close();
        }
        process.destroy();
      } catch (Exception e) {
      }
    }
    return true;
  }

}

Related Tutorials