Call package manager (pm)
Within an adb shell, you can issue commands with the package manager (pm) tool to perform actions and queries on app packages installed on the device. You can issue a package manager command directly from adb without entering a remote shell. For example:
adb shell pm uninstall com.example.MyApp
Prints all packages, optionally only those whose package name contains the text in
-f: See their associated file.
-d: Filter to only show disabled packages.
-e: Filter to only show enabled packages.
-s: Filter to only show system packages.
-3: Filter to only show third party packages.
-i: See the installer for the packages.
-u: Also include uninstalled packages.
--user user_id: The user space to query.
adb shell pm list packages [options] filter
Prints all known permission groups.
adb shell pm list permission-groups
Prints all known permissions, optionally only those in
-g: Organize by group.
-f: Print all information.
-s: Short summary.
-d: Only list dangerous permissions.
-u: List only the permissions users will see.
adb shell pm list permissions [options] group
List all test packages. Options:
-f: List the APK file for the test package.
target_package: List test packages for only this app.
adb shell pm list instrumentation [options]
Prints all features of the system.
adb shell pm list features
Prints all the libraries supported by the current device.
adb shell pm list libraries
Prints all users on the system.
adb shell pm list users
Print the path to the APK of the given
adb shell pm path package
Installs a package (specified by
path) to the system.
-l: Install the package with forward lock.
-r: Reinstall an existing app, keeping its data.
-t: Allow test APKs to be installed. Gradle generates a test APK when you have only run or debugged your app or have used the Android Studio Build > Build APK command. If the APK is built using a developer preview SDK (if the
targetSdkVersionis a letter instead of a number), you must include the
-toption with the
installcommand if you are installing a test APK.
-i installer_package_name: Specify the installer package name.
-s: Install package on the shared mass storage (such as sdcard).
-f: Install package on the internal system memory.
-d: Allow version code downgrade.
-g: Grant all permissions listed in the app manifest.
adb shell pm install [options] path
Removes a package from the system. Options:
-k: Keep the data and cache directories around after package removal.
adb shell pm uninstall [options] package
Deletes all data associated with a package.
adb shell pm clear package
Enable the given package or component (written as "package/class").
adb shell pm enable package_or_component
Disable the given package or component (written as "package/class").
adb shell pm disable package_or_component
--user user_id: The user to disable.
adb shell pm disable-user [options] package_or_component
Grant a permission to an app. On devices running Android 6.0 (API level 23) and higher, the permission can be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.
adb shell pm grant package_name permission
Revoke a permission from an app. On devices running Android 6.0 (API level 23) and higher, the permission can be any permission declared in the app manifest. On devices running Android 5.1 (API level 22) and lower, must be an optional permission defined by the app.
adb shell pm revoke package_name permission
Changes the default install location. Location values:
0: Auto: Let system decide the best location.
1: Internal: install on internal device storage.
2: External: on external media.
Note: This is only intended for debugging; using this can cause apps to break and other undesireable behavior.
adb shell pm set-install-location location
Returns the current install location. Return values:
0 [auto]: Lets system decide the best location
1 [internal]: Installs on internal device storage
2 [external]: Installs on external media
adb shell pm get-install-location
Specifies whether the given permission should be enforced.
adb shell pm set-permission-enforced permission [true | false]
Trim cache files to reach the given free space.
adb shell pm trim-caches desired_free_space
Create a new user with the given
user_name, printing the new user identifier of the user.
adb shell pm create-user user_name
Remove the user with the given
user_id, deleting all data associated with that user
adb shell pm remove-user user_id
Prints the maximum number of users supported by the device.
adb shell pm get-max-users