1

as per question, I know if I run my app on an emulator, I can retrieve a copy of the generated sqlite table by just going to the /bin folder. But how can I do the same, if I run my app on my device?

edit: it seems I was right on the part that I can retrieve the sqlite table by going to the /bin folder, only if I am using Eclipse. But currently I'm using Android Studio... so anyone here knows how to retrieve the generated sqlite table?

imin
  • 4,504
  • 13
  • 56
  • 103
  • you need to root your device for accessing database – MHP Aug 27 '14 at 16:14
  • @MHP ouch that's going to be a problem for me than.. anyway you have any idea on how to retrieve generated sqlite tables if I use Android Studio? – imin Aug 27 '14 at 16:22
  • you can do it after app installed and database created by some code – MHP Aug 27 '14 at 16:24
  • yup @MHP my app was already installed and database was already created.. the problem is I don't know how can I copy the generated database to somewhere else. I can do this without any problem when I use eclipse, but on Android Studio, I don't know where's the physical location Android Studio puts the generated sqlite database.. – imin Aug 27 '14 at 16:25
  • see this http://stackoverflow.com/questions/5282936/android-backup-restore-how-to-backup-an-internal-database – MHP Aug 27 '14 at 16:34

1 Answers1

0

You can retrieve your sqlite-databases even if your device isn't rooted. Here's how:

Step 1 - Open adb command prompt

Go to your android-sdk folder --> platform-tools and open the command prompt.

Step 2 - Backup

Enter the following line in your command prompt:

adb backup -f my_backup.ab -noapk com.mypackage.name

Unlock your device and you should see something like this:

adb backup screenshot

Confirm the backup-operation without entering a password

Note: This will only work on devices running Android 4.0 and above

Step 3 - Unpacking the backup

Now you should see a file called my_backup.ab in your platform-tools folder. That's a compressed and encrypted backup file of android which we need to extract now. Download the following tool called Android Backup Extractor.

Now extract the *.zip file of the Android Backup Extractor and copy your *.ab file into this directory. And run the following command:

java -jar abe.jar unpack my_backup.ab my_backup.tar

Afterwards a new archive should appear called my_backup.tar. Open it an browse to the /db/ directory. There you'll see all of your databases. Done!

reVerse
  • 35,075
  • 22
  • 89
  • 84