How to uninstall Android App with root permissions?

随声附和 提交于 2019-12-02 15:14:09

问题


I wrote something to uninstall (delete) an App and have now the problem that the apk seems to be deleted but the app is not really deleted from phone..

The supposedly deleted app still exists in the launchers app drawer. And I can open the app, but it force closes the app.

I tested the procedure with an own App (existing at /data/app, not /system/app). With systemapps I didn't test.

Here the code:

private void delApp() {
    String deleteCMD = "rm " + packageInfo.applicationInfo.sourceDir;


    Process process;
    try 
    {
        process = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(process.getOutputStream());
        os.writeBytes("mount -o remount,rw -t rfs /dev/stl5 /system; \n");          
        os.writeBytes(deleteCMD+"; \n");
        os.writeBytes("mount -o remount,ro -t rfs /dev/stl5 /system; \n");
        os.flush();

    } 
    catch (IOException e) 
    {
        e.printStackTrace();
    }      



}

回答1:


I don't rightly know why what you're doing does not work, maybe someone else can shed some light on that.

You could try:

pm uninstall com.package.name

instead of your rm /package/dir/path method

I'm not sure if that works on apps in the /system/app directory, however.

Also, take a look at: Application launcher icon is not deleted from Home screen when uninstalling android app



来源:https://stackoverflow.com/questions/15661782/how-to-uninstall-android-app-with-root-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!