获取 room

引用:http://wiseideal.iteye.com/blog/1166794

转载自:http://dev.10086.cn/cmdn/bbs/thread-37036-1-1.html 
Java代码  收藏代码
  1. public static boolean runRootCommand(String command) {  
  2. Process process = null;  
  3. DataOutputStream os = null;  
  4. try {  
  5. process = Runtime.getRuntime().exec("su");   
  6. os = new DataOutputStream(process.getOutputStream());  
  7. os.writeBytes(command+"\n");  
  8. os.writeBytes("exit\n");  
  9. os.flush();  
  10. process.waitFor();  
  11. catch (Exception e) {  
  12. Log.d(TAG, "the device is not rooted, error message: " + e.getMessage());  
  13. return false;  
  14. finally {  
  15. try {  
  16. if (os != null) {  
  17. os.close();  
  18. }  
  19. if(process != null) {  
  20. process.destroy();  
  21. }  
  22. catch (Exception e) {  
  23. e.printStackTrace();  
  24. }  
  25. }  
  26. return true;  
  27. }  
 
posted @ 2012-03-07 23:57  镇水古月  阅读(199)  评论(0编辑  收藏  举报