Reputation: 33
I want to copy file from data/data/mypackage
to /mnt/sdcard
but when i apply the command line nothing happened. My mobile is rooted and I have permeation to make this command.I have array list and put all my command inside this array after get all command "getCommandsToExecute()
" method and apply all my command:
public final boolean execute() {
boolean retval = false;
try {
ArrayList<String> commands = getCommandsToExecute();
if (null != commands && commands.size() > 0) {
Process suProcess = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
suProcess.getOutputStream());
// Execute commands that require root access
for (String currCommand : commands) {
os.writeBytes(currCommand + "\n");
os.flush();
}
os.writeBytes("exit\n");
os.flush();
try {
int suProcessRetval = suProcess.waitFor();
if (255 != suProcessRetval) {
// Root access granted
retval = true;
} else {
// Root access denied
retval = false;
}
} catch (Exception ex) {
Log.e("ROOT", "Error executing root action", ex);
}
}
} catch (IOException ex) {
Log.w("ROOT", "Can't get root access", ex);
} catch (SecurityException ex) {
Log.w("ROOT", "Can't get root access", ex);
} catch (Exception ex) {
Log.w("ROOT", "Error executing internal operation", ex);
}
return retval;
}
My array list have this command:
ArrayList<String> hi= new ArrayList<String>();
hi.add("shell cp /data/data/com.askfm/databases /mnt/sdcard");
Upvotes: 0
Views: 918
Reputation: 16832
You have to use cat src >dest
There's no cp
command in an out-of-box Android. There are tools like BusyBox (here, there), but they must be installed separately.
Upvotes: 1