Marcos Vasconcelos
Marcos Vasconcelos

Reputation: 18276

Acess files on root in device

I'm developing an application for Galaxy Tab, and now I need get some files on the /data/data// folder.

The emulator is really, really slow. So I'm testing on device, and need get the files from device (from emulator i'm able to do). How can I do that?

Upvotes: 2

Views: 693

Answers (3)

Matthew
Matthew

Reputation: 44919

adb pull <path>

will download files from the device to your current directory.

You can also use adb shell to explore your device using common shell commands. adb shell ls <path> will let you do this without actually entering the shell completely.

Edit - this will not work for files in the /data directory or other restricted directories unless you have root access to the device.

Upvotes: 1

Rok
Rok

Reputation: 2578

Add a debug function in your code to copy the required files from the protected folders onto your phone's SD card. You can then access them from your PC.

public static void backupFile() throws IOException {

  String inFileName = "/data/data/your.package.name/........"; //TODO Use folder/filename
  File inFile = new File(inFileName);
  FileInputStream fis = new FileInputStream(inFile);

  String outFileName = Environment.getExternalStorageDirectory()+"/........"; //TODO Use output filename
  OutputStream output = new FileOutputStream(outFileName);

  byte[] buffer = new byte[1024];
  int length;
  while ((length = fis.read(buffer))>0)
    output.write(buffer, 0, length);

  output.flush();
  output.close();
  fis.close();
}

Upvotes: 5

slund
slund

Reputation: 6397

The /data directory on a device has restricted permissions. To copy files off using adb you will need to have rooted your device.

Upvotes: 3

Related Questions