Search code examples
androidadbroot

Use Adb programmatically


How can I Push my apk from the Data Folder to the System/App Folder using a Rooted Device, programmatically using Runtime.getRuntime().exe.

Should I use Pull, Push or Cat Command and how?

Does it will affect Shared Prefs or anything?


Solution

  • Try

    Runtime.getRuntime().exec("pm install -r "/path/to/yourfilename.apk";)
    

    Usage pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] [--algo --key --iv ] PATH

    options :

    -l: install the package with FORWARD_LOCK.
    -r: reinstall an exisiting app, keeping its data.
    -t: allow test .apks to be installed.
    -i: specify the installer package name.
    -s: install package on sdcard.
    -f: install package on internal flash.
    

    Depending on your usage of the -r parameter, it will affect the shared preferences xml files (use to not lose).