-1

I tried to uninstall apps on my rooted phone,and I usethe code from How to uninstall Android App with root permissions? ,and I tried the suggestion but I failed. Here is my code:

Process process;
try {
    process = Runtime.getRuntime().exec("su");
    DataOutputStream os = new DataOutputStream(process.getOutputStream());
    os.writeBytes("pm uninstall com.lixiancheng.orangemusic"+"; \n");
    os.flush();
} catch (IOException e) {
    e.printStackTrace();
}  

Why i can't uninstall the app?is any problem with the code?

Community
  • 1
  • 1
orzangleli
  • 178
  • 7

2 Answers2

1

Have You tried:

try {
    Process su = Runtime.getRuntime().exec("su");
    DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());

    outputStream.writeBytes("pm uninstall com.lixiancheng.orangemusic\n");
    outputStream.flush();
    outputStream.writeBytes("exit\n");
    outputStream.flush();
    su.waitFor();
} catch(IOException e){
    throw new Exception(e);
} catch(InterruptedException e){
    throw new Exception(e);
}
3mpty
  • 1,354
  • 8
  • 16
0

Type adb shell rm -f/{data,system}/app/APKNAME”, replace “APKNAKE” with the name of the application you want to delete and press Enter.

Drake29a
  • 896
  • 8
  • 23