android 编程获取root权限,该怎么解决

android 编程获取root权限
如题 手机已经获取root权限 
  如何编程 获取root权限  
要修改System下的文件 不知道 其他权限是否可以
网络上看到的代码
Process process = null;
  try
  {
  process = Runtime.getRuntime().exec("su");
  //这里是主要程序代码ATAAW.COM
  process.waitFor();
   
  }
  catch(Exception e)
  {
  e.printStackTrace();
  }
  finally 
  {
  process.destroy();
  }

运行后 就黑屏了

------解决方案--------------------
Java code

public static boolean rootCommand(String command)  
    {  
        Process process = null;  
        DataOutputStream os = null;  
        try{  
            process = Runtime.getRuntime().exec("su");  
            os = new DataOutputStream(process.getOutputStream());  
            os.writeBytes(command + "\n");  
            os.writeBytes("exit\n");  
            os.flush();  
            process.waitFor();  
        } catch (Exception e){  
            Log.d("*** DEBUG ***", "ROOT REE" + e.getMessage());  
            return false;  
        } finally {  
            try{  
                if (os != null) {  
                    os.close();  
                }  
                process.destroy();  
            } catch (Exception e) {  
            }  
        }  
        Log.d("*** DEBUG ***", "Root SUC ");  
        return true;  
    }