获取Android中文件的权限(根) [英] Get file permissions in Android (root)

查看:135
本文介绍了获取Android中文件的权限(根)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过一番摆弄根设备,我被困上的文件。比方说,我们在这我想读我的应用程序/写的根文件夹某处的一个文件。我迄今发现的唯一方法是改变像文件权限

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?

推荐答案

不要的ls -l <​​/ code>的文件/目录,并解析输出

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

编辑由OP:的解决方案是这个线程。这个答案只是把我推在正确的方向。

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

这篇关于获取Android中文件的权限(根)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆