How to backup / restore a paid Android app’s SQLite database without root

On a non-rooted Android phone, it is not possible to read a paid app’s data folder from adb, as the /mnt/asec directory will be protected. However, the databases and files in the data directory can still be backed up using adb’s backup feature.

  1. Make sure USB debugging is enabled, and connect the phone to a Linux computer, preferably running some flavour of Ubuntu, such as Mint.
  2. Open a terminal on the computer, navigate to the platform-tools directory of your SDK install directory, and run
    adb backup -noapk com.your.packagename

    replacing com.your.packagename with the package name of your app. If you don’t know the package name of your app, run this command to list all packages, and locate the one for the app you wish to backup

    adb shell 'pm list packages -f'
  3. You will now be prompted to ‘unlock your device and confirm the backup operation’. To simplify extracting the data, do NOT provide a password for this operation on the phone. Click ‘backup my data’, and the backup process should start. You will have to wait for the command to complete, there is no progress indicator. Once the backup process has completed, you will find a file named backup.adb in your current folder.
    ics-backup

  4. Now the tricky part is extracting the data. The data can be extracted with openssl’s zlib, but Ubuntu’s openssl is compiled with zlib support disabled. If you run openssl zlib, you will get an error: openssl:Error: ‘zlib’ is an invalid command. You will have to use zlib-flate instead.
    cat backup.ab | (dd bs=24 count=0 skip=1; cat) | zlib-flate -uncompress > backup.tar
  5. When done, you should have a tar file that can be extracted with archive manager. Once extracted, you will find the app’s SQLite databases in the “apps/com.your.packagename/db” directory.

To restore, you can’t simply copy the files back. Instead you will have to use the restore command:

adb restore  backup.ab

Leave a Reply

Your email address will not be published. Required fields are marked *

six − 2 =