Giovanni Mariotti
Giovanni Mariotti

Reputation: 635

shell command programmatically that don't work

i'm tring to copy one file by one directory to another. i'm using the "cp" function. this is the code

Process process = Runtime.getRuntime().exec("cp "+path+" "+destinationFolder);

this code work well on many device but in other i get this error

error running exec(cp, /data/app/myApp.apk, mnt/sdcard/destinationFolder.

working directory null, envinroment null. caused by ioException permission denied why i'm getting this error and how can i solve? any help is

Upvotes: 0

Views: 227

Answers (2)

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

error running exec(cp, /data/app/myApp.apk, mnt/sdcard/destinationFolder

Looks your destination path lacks root slash as it should be /mnt/sdcard/destinationFolder not mnt/sdcard/destinationFolder as quoted error message indicates

Upvotes: 1

Martin Cazares
Martin Cazares

Reputation: 13705

This error could be vendor dependant, obviously the error is lack of permissions when trying to copy the files in /data/app/, most of the devices won't let you do that unless the device is rooted and you are using sudo commands, if you are trying to attack a global market with your application I'm sure you will have a lot of problems with that, and you should find a better approach.

Hope this Helps

Regards!

Upvotes: 0

Related Questions