Black
Black

Reputation: 81

ADB PULL Command

I am trying to use adb for working with the files in my device from a MAC PC.

One of my folders in my phone has a space in it, so I looked around and tried using escape i.e \ and also using quotes with as given below

import java.io.*;
public class TestModule {
public static void main(String[] args) throws IOException,InterruptedException {
String line = "null";
String cmd = "adb pull /storage/sdcard1/Android/data/files/test\\ Information/ /Users/sbc/Desktop";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
}
}

I ran the same command in terminal I can access the file but through java it gives me remote object does not exist error.

Any help is very much appreciated

Upvotes: 1

Views: 1643

Answers (1)

Black
Black

Reputation: 81

I found a workaround for my problem, posting code below,

import java.io.*;
public class TestModule {

public static void main(String[] args) throws IOException,InterruptedException {

String line = "null";
String cmd = "adb pull /storage/sdcard1/Android/data/files /Users/sbc/Desktop";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream()));
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
}
}

In place of accessing the folder with the space, I accessed it's parent folder /storage/sdcard1/Android/data/files/test\ Information/<--current folder with space /storage/sdcard1/Android/data/files<--Parent Folder.

Now adb downloads all the contents of "Parent Folder"

Upvotes: 1

Related Questions