Read or write file to / data on Android root device

I am trying to programmatically read / write a file in the / data directory on the root phone. First I run su to make sure my program gets superuser access, which works fine.

I can read / write files to / data thru shell execs in my program, but I get a " Permission denied " java.io.IOException when using an Android file or other APIs.

How to use the API to read / write to / data on the root phone? this is obviously possible since programs like Root Explorer do this.

Thank,

+3
source share
2 answers

, , API, , root, .

su, root.
github Chainfire Shell, rm , root.

, , - , , , /sdcard/tmp.txt, , .

chmod (.. chmod 777 /data/xxx.txt), . Permission denied, . , , chmod ​​ su, THAT . , , , root.

: How-To SU

+2

,

Runtime.getRuntime().exec("chmod 077" +your_file_you_need_to_give_permission); 
+1

All Articles