Aprel
Aprel

Reputation: 1179

How to read Files from Systemfolders

I have android device with root and i try to implement some small app. This app need to read files from /proc/pid/net . I made it with Runtime.getRuntime().exec(new String[] { "su", "-c", "cat /proc/"+PID+ "/net/tcp6" }); but I must accept su -permission for each pid. There are some other possibilities how i can to read system files in android from my app? Something with FileReader? How can I get the su-permissions without exec -commando?

Upvotes: 0

Views: 805

Answers (1)

Reed
Reed

Reputation: 14984

The exec command IS how you get su permissions. You might be able to chmod 777 the files you want and then they can likely be read via java. That, or you could move the files you want to read to the sdcard, or your apps data location and read them from there. Here is something very useful for root. You won't have to manually use the exec command each time, but RootTools does still use exec.

I believe if you do something like:

Process p = Runtime.getRuntime().exec("su");

you will get the root access.
And then you can do just:

p.getRuntime().exec("command");

and then you won't have to put the su in as long as that process is still active.

Though, I haven't done what I explained above (with the process) in quite some time, so I may be wrong. You may still have to include su each time. But either way, I'd recommend using RootTools.

Upvotes: 1

Related Questions