I try to access to my folder in sdcard and install myapp.apk, i use this code:
Runtime.getRuntime().exec(\"cd sdcard/.yasmin\");
Runtime.getRuntime().exec(\"ad
- Get the process of the exec() using: Process p = Runtime.getRuntime().exec(...).
- Grab the process inputStream using p.getInputStream();.
- Run the second command.
I would have posted it as a comment to MByD's answer but I don't have 50 reputation yet so StackOverflow won't let me.
For the second step you are supposed to use DataOutputStream
instead of DataInputStream
to write commands to the shell. InsputDataStream
is for the opposite purpose in fact that is to read output.
If it sounds confusing then think of it this way:
You are outputting the commands through the Android Debug Bridge (ADB) to the shell hence using DataOutputStream
. On the other hand you are getting result through the ADB from the shell hence using DataInputStream
.