public boolean RootCmd(String cmd)
    {  
     Process process = null;  
     DataOutputStream os = null;  
     try
     {  
     //process = Runtime.getRuntime().exec("su");
     process = Runtime.getRuntime().exec("su -c XXXX");
     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;  
    }  
调用方法
String apkRoot="chmod 777 "+ getPackageCodePath(); 
RootCmd(apkRoot);  这个方法可以获取到root权限  是在已经获取root权限的手机上运行的
 不过   后来  就又不行了   时好时坏刚刚那段代码 我是在setContentView(R.layout.main); 后马上调用的
请问 是不是调用的地方有问题  还是说方法有问题
 希望大家 多帮帮忙