I have recently struggled with getting data out of my own Android application that I have installed from Play Store and wanted to backup my data before deploying new development version. These so-called app specific data are protected so that other apps cannot see them and what’s more, it is not straightforward for users to see them, either.

Note that any app can disable data extraction described in this post by setting android:allowBackup to false.

Extracting data

I assume you have adb installed and your Android device connected with developer mode enabled on it. In following commands, replace com.example.app with your chosen application ID.

To backup data, execute:

adb backup -f backup.ab -apk com.example.app

Note that adb reports that this command is deprecated, but you can ignore it:

WARNING: adb backup is deprecated and may be removed in a future release

Then, a prompt on your Android device will be shown:

Android Backup Confirmation Screenshot

Click “Backup My Data” to complete the backup.

The created backup.ab file is almost an archive but without header. You can extract data from it using one-line command (if you are on Windows, use your WSL bash):

( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 backup.ab ) | tar xfvz -

Data of your app will be extracted into folder apps/com.example.app/.

Restoring data

To restore the (possibly modified) data into a development version of my app, I use Android Studio’s Device File Explorer and its “Upload” option.

If you need to restore the created backup (you don’t even need to extract it in the first place), you can simply use command inverse to adb backup:

adb restore backup.ab
Let me know what you think and feel free to ask questions about this post in comments below.