Install apk using root?

1.8k views Asked by At

Is there a way of installing an apk from downloads folder without user input on a rooted device?

1

There are 1 answers

4
kenarsuleyman On

You can simply use adb install command to install/update APK silently. Sample code is below

public static void InstallAPK(String filename){
    File file = new File(filename); 
    if(file.exists()){
        try {   
            String command;
            command = "adb install -r " + filename;
            Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
            proc.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }
     }
 }