android : how to run a shell command from within code
- by ee3509
I am trying to execute a command from within my code,
the command is "echo 125 /sys/devices/platform/flashlight.0/leds/flashlight/brightness"
and I can run it without problems from adb shell
I am using Runtime class to execute it :
Runtime.getRuntime().exec("echo 125 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness");
However I get a permissions error since I am not supposed to access the sys directory.
I have also tried to place the command in a String[] just in case spaces caused a problem but it didn't make much differense.
Does anyone know any workaround for this ?