How to list Android apps in the order they were installed

This blog post explains how to list applications on an Android device (phone, tablet etc.) in the order they were installed. This list can be used to copy the most recently installed application from the device to the computer.

Enable USB debugging on the phone, and connect the phone. (If you don't know how, follow these steps up to the point of running adb shell.) Make sure adb shell id works. Then run the following command on your computer (without the leading $):

adb shell 'pm list packages -f | while read X; do
    X="${X#package:}"; X="${X%=*}"; L="$(ls -l "$X")";
    echo "${L% *} $X"; done' | sort -k 5

This will list the applications in installation order, i.e. the most recently installed one will be listed last. The full name of the applications are not displayed, but the filename and directory name of the .apk files is.

If /data/app/X.Y.apk is listed, then copy it to the computer like this:

$ adb pull /data/app/X.Y.apk

No comments: