I am using the following command from Java and it works with my old phone

 adb shell svc data disable

But with my new phone I am required to change to root (su command) in shell before I can successfully execute svc data disable

Is it possible to do this in one command? I use Java's Process exec method to run this command, and I'm not how to make it work with my new phone since I am required to change the shell to root first.

  • On terminal emulator putting && between the two commands works (second command executed only on successful completion of first). Alternatively ; between two commands. I don't know if it same for Java – beeshyams Feb 4 '17 at 7:15
  • I tried adb shell && su on windows command line manually but it only tries to execute su after I press ctrl-d, I think su does not get executed since the shell command has not really finished executing while we are still in shell. – Arya Feb 4 '17 at 8:05
  • 1
    found the answer on stackoverflow stackoverflow.com/questions/8761992/… – Arya Feb 4 '17 at 8:12
  • 1
    You can answer the question yourself :) – beeshyams Feb 4 '17 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.