Get file permissions in Android (root)

冷暖自知 提交于 2019-12-10 10:24:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/15890142/get-file-permissions-in-android-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!