1

I want to copy files and directories from /root directory to a different folder inside the SD_CARD. So, I did lots of search, but couldn't found a useful answer.

I executed su command like this:

Process pp  = Runtime.getRuntime().exec("su cp "+originDir+"  "+targetDir);

Any help will be great. Thanks.

Amol Nage
  • 85
  • 10
  • 2
    Make sure you have root on your android device. If you don't have root, you won't be able to access that directory. Then follow [this question](http://stackoverflow.com/questions/20932102/execute-shell-command-from-android) to see the proper way of executing commands as root – BackSlash Nov 14 '16 at 11:35
  • now it showing ' java.io.IOException: Broken pipe:' – Amol Nage Nov 14 '16 at 12:03
  • Not every rooted device has the `cp` command installed. Usually you need BusyBox for the `cp` command. Furthermore you should read the cp documentation/SO for copying directories. E.g [here](http://stackoverflow.com/questions/14922562/how-do-i-copy-folder-with-files-to-another-folder-in-unix-linux). – Robert Nov 14 '16 at 12:49
  • is it not possible without BusyBox ? – Amol Nage Nov 15 '16 at 06:52

1 Answers1

1

Try Using RootTools library for android. (RootTools: a library to run commands as root).

RootTools provides rooted developers a standardized set of tools for use in the development of rooted applications.

You can find the latest release here: https://github.com/Stericson/RootTools/releases

You can find more informaiton on our wiki: https://github.com/Stericson/RootTools/wiki

For a more slimmed down library, check out RootShell: https://github.com/Stericson/RootShell

Hope this will help you.

Priya Jagtap
  • 1,023
  • 13
  • 19