Created
March 12, 2015 11:15
-
-
Save sandeep048/a2ad77012f8f8767fc04 to your computer and use it in GitHub Desktop.
This simple script will backup user installed android applications to the computer. Extremely useful when there is not enough space in the phone. Requires working 'adb shell'.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
adb_process = subprocess.Popen( | |
'adb shell pm list packages -f', shell=True, stdout=subprocess.PIPE) | |
user_packages = [] | |
while True: | |
output_line = adb_process.stdout.readline().strip() | |
if len(output_line) == 0: | |
break | |
if 'data' in output_line: | |
user_packages.append(output_line) | |
for fpath, fname in [(x.split(':')[1].split('=')[0], x.split('=')[1] + '.apk') for x in user_packages]: | |
subprocess.Popen('adb pull %s %s' % | |
(fpath, fname), shell=True, stdout=subprocess.PIPE) | |
# adb_output, adb_error = process.communicate() | |
# print user_packages | |
# adb_output, adb_error = process.communicate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learn how to use adb backup to save app data as well when the mobile is rooted.