我写了一个apk的小程序,我的手机已经root了,我想让这个apk访问系统的文件,怎么做那,直接读写得话提示权限不够。
很急!!!!我想手机都已经root了怎么还有一堆限制哪??
不懂,希望大家讲讲。
很急!!!!我想手机都已经root了怎么还有一堆限制哪??
不懂,希望大家讲讲。
解决方案 »
- OpenGL 贴图问题
- java.lang.IllegalStateException: Scheme 'http' not registered.异常
- Assets 目录下的文件夹大小限制吗?
- Android Base64+Soap+WebService 图片上传内存溢出问题
- 【请教内行】我用socket编程,模拟器能连通网络找到服务器。。。
- 小菜一个简单的问题,莫鄙视,求回答,谢谢!
- Android cts 一些fail 求pass方法
- android应用“图钉”是怎么实现在自己的应用里面输入用户名和密码通过sina微博授权的
- 为啥listview只显示一部分信息?
- 安卓开发能否使用access数据库
- Button r=new Button(this); 就出错,不知道什么原因?
- MapView使用中出现的错误,各位大神进来看看 Couldn't get connection factory client
在程序中执行:
Runtime.getRuntime().exec("su");
然后对返回的process操作就ok了。就等于你在用linux 的命令窗口。
需手動修改待訪問文件權限!程序中執行execRootCmd("chmod 777 待讓問文件完整路徑");
如execRootCmd("chmod 777 /system/app/a.apk");protected static Vector execRootCmd(String paramString) { Vector localVector = new Vector(); try { Process localProcess = Runtime.getRuntime().exec("su ");//经过Root处理的android系统即有su命令 OutputStream localOutputStream = localProcess.getOutputStream(); DataOutputStream localDataOutputStream = new DataOutputStream(localOutputStream); InputStream localInputStream = localProcess.getInputStream(); DataInputStream localDataInputStream = new DataInputStream(localInputStream); String str1 = String.valueOf(paramString); String str2 = str1 + "\n"; localDataOutputStream.writeBytes(str2); localDataOutputStream.flush(); String str3 = localDataInputStream.readLine(); localVector.add(str3); localDataOutputStream.writeBytes("exit\n"); localDataOutputStream.flush(); localProcess.waitFor(); return localVector; } catch (Exception localException) { localException.printStackTrace(); } }
Runtime.getRuntime().exec("su");如果你要访问的系统文件没有权限,adb shell 进入手动chmod下,或者如LS所示。不过我猜应该不是这种情况,读权限不会作这么大限制的……除非你说的访问是写。