You can use an open source library to run the command as root. Check out the following libraries:
https://github.com/Stericson/RootTools
https://github.com/SpazeDog/rootfw
https://github.com/Chainfire/libsuperuser
https://github.com/dschuermann/superuser-commands
Or do it yourself:
java
Process su = null;
try {
su = Runtime.getRuntime().exec("su");
String cmd = "pm install /path/to/the/apk\n";
su.getOutputStream().write(cmd.getBytes());
String exit = "exit\n";
su.getOutputStream().write(exit.getBytes());
su.waitFor();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (su != null) {
su.destroy();
}
}