shell - How I can Copy file by command line in android? -


i want copy file data/data/mypackage /mnt/sdcard when apply command line nothing happened. mobile rooted , have permeation make command.i have array list , put command inside array after command "getcommandstoexecute()" method , apply 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 require root access                 (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 root access", ex);         } catch (securityexception ex) {             log.w("root", "can't root access", ex);         } catch (exception ex) {             log.w("root", "error executing internal operation", ex);         }          return retval;     } 

my array list have command:

arraylist<string> hi= new arraylist<string>(); hi.add("shell cp /data/data/com.askfm/databases /mnt/sdcard"); 

you have use cat src >dest

there's no cp command in out-of-box android. there tools busybox (here, there), must installed separately.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -