Reputation: 387
I want to execute adb commands like adb backup -noapk com.your.packagename
directly in my android app.
How can I do it? Is it possible or do I have to use an Android API?
I want to write an Android app using Java and be able to run it as if I had a terminal with adb in it.
Upvotes: 2
Views: 2394
Reputation: 4897
Try this:
private void runAdbCommands(String command) {
ProcessBuilder pb = new ProcessBuilder(command);
Process pc = null;
try {
pc = pb.start();
} catch (IOException e) {
e.printStackTrace();
}
try {
pc.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Done");
}
Upvotes: 2
Reputation: 1034
You want to execute the adb client, and you can't find it in Android system. What is executed in Android is the adb server, in listening for adb clients launched from external OS.
Upvotes: 0