adb pull app from android code example

Example: how to pull apk of any app through adb

# Determine the package name of the app, e.g. "com.example.someapp". Skip this step if you already know the package name.
adb shell pm list packages
# Look through the list of package names and try to find a match between the app in question and the package name.
adb shell pm path com.example.someapp
# Using the full path name from Step 2, pull the APK file from the Android device to the development box.
adb pull /data/app/com.example.someapp-2.apk path/to/desired/destination