Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public void uninstallApp(String packageName){
  2. try {
  3.  
  4. String[] command = new String[4];
  5. command[0] = "su";
  6. command[1] = "mount -o remount,rw /system";
  7. command[2] = "rm " + packageName;
  8. command[3] = "reboot";
  9. Runtime run = Runtime.getRuntime();
  10. run.exec(command);
  11.  
  12. Log.d("DELETED", packageName);
  13.  
  14. } catch (Exception e) {
  15. // TODO Auto-generated catch block
  16. Log.e("ERROR ON DELETE", e.getMessage());
  17. }
  18. }
  19.  
  20. StringBuilder cmdReturn = new StringBuilder();
  21.  
  22. try {
  23. ProcessBuilder processBuilder = new ProcessBuilder("su","-c mount -o remount,rw /system ; rm " + packageName + " ; reboot");
  24. Process process = processBuilder.start();
  25.  
  26. InputStream inputStream = process.getInputStream();
  27. int c;
  28. while ((c = inputStream.read()) != -1) {
  29. cmdReturn.append((char) c);
  30. }
  31.  
  32. Log.d("CMD RESPONSE", cmdReturn.toString());
  33.  
  34. } catch (IOException e) {
  35. // TODO Auto-generated catch block
  36. e.printStackTrace();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement