Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get file permissions in Android (root)

After some play around with rooted devices, I got stuck on the files. Let's say we have a file somewhere in the root folder which I want to read/write from my application. The only way I found so far is changing the file permission like

String [] cmd = { "su", "-c", "chmod", "777", path};
Process process = new ProcessBuilder(cmd).start();
process.waitFor();

This works fine, the problem is that I want to return back the original file permissions after I'm done with it.

Can anybody help me with getting a file/directory current permissions?

like image 414
mihail Avatar asked Feb 25 '26 00:02

mihail


1 Answers

Do ls -l on file/directory and parse the output

EDIT BY OP: the solution is in this thread. This answer just pushed me in the right direction.

like image 63
Marcin Orlowski Avatar answered Feb 26 '26 12:02

Marcin Orlowski