0

I am unable to View or Pull my SQLite database file created by my application on my device.

Here is how I tried to pull it using ADB

E:\>adb pull /data/data/com.example.testinglist/databases/timetracker.db failed to copy '/data/data/com.example.testinglist/databases/timetracker.db' to './timetracker.db': **Permission denied**

As you can see there is a Permission denied error.

I can't see or copy file using FileExplorer in Eclipse ADT. Only folder data can be copied as unable to move in the folder in FileExplorer. and folder Data copied to computer using FileExplorer is empty. Any solutions please??enter image description here

RehanZahoor
  • 322
  • 2
  • 12

2 Answers2

0

If your device isn't rooted, you may use this code to export your applications database onto your sdcard:

try {
   File dstDb = new File(dstPathOnSdcard, dstFileName);
   FileOutputStream output = new FileOutputStream(dstDb);

   File srcDb = new File(Environment.getDataDirectory(), "//data//com.mynamespace.myapp//databases//mydatabasename.db");
   FileInputStream input = new FileInputStream(srcDb);

   FileChannel src = input.getChannel();
   WritableByteChannel dst = Channels.newChannel(output);

   src.transferTo(0, src.size(), dst);

   src.close();
   input.close();
   dst.close();
   output.close();
} 
catch (Exception e) {
   // doSomething
}
Kirby
  • 86
  • 1
  • 8
0

This is how I do it (on an ubuntu machine, without root):

  1. Locate adb file in Android/Sdk/platform-tools/
  2. Open command line in this directory
  3. Run the following code, to pull Sqlite database from app to SD card:

    ./adb -d shell "run-as com.example.name.myappname cp /data/data/com.example.name.myappname /databases/database.db /sdcard/database.db"

*Make sure to replace "database.db" and "com.example.name.myappname", by your databasename and app name (found in your manifest).

  1. Run the following code, to pull the Sqlite data from SD card to desktop:

    ./adb -d pull /sdcard/database.db ~/Desktop/database.db

Tom O
  • 2,495
  • 2
  • 19
  • 23