Tag: file

Backing up, importing and restoring databases on Android

If your Android application has a database and you want your users to be able to backup the database and restore it as they see fit, you’ll need to mess about with database files.

Below is a class called DbExportImport. Once you’ve set it up with the correct values, all you need to do is call exportDb(), importDb() or restoreDb() from your application to perform the necessary operations.

This is also useful as a temporary measure when changing your package name or key for application signing, as your application will be newly installed and you will lose your database.

I have only left in a few comments, so for any clarification, leave a comment and I’ll make it a little clearer.

ADB ‘Push: Permission Denied’ on Android adb shell push

I just spent a little while trying to figure out why I was getting ‘push: permission denied’ when running:

I did some googling to no avail.

Then I remembered that pushing and pulling is not done in the shell, it’s just done with adb.

Thus, it should have been:

Which succeeds. I know it’s a silly error to make, but I thought I’d share this in case anybody else uses the adb shell push instead of regular adb push and can’t figure out why permission is denied.