最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android内部存储改变读取权限的方法
时间:2018-08-09 编辑:猪哥 来源:一聚教程网
在开发时,手机先要ROOT,然后在通过代码改变权限。
public synchronized static boolean getRoot(String paramString)
{
Process process = null;
DataOutputStream os = null;
try
{
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(paramString + "n");
os.writeBytes("exitn");
os.flush();
process.waitFor();
} catch (Exception localException)
{
System.out.println("@@@@root cmd error:"+localException);
//localException.printStackTrace();
return false;
}finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
System.out.println("###root cmd error:"+e);
}
}
return true;
}
引用时需要注意加入权限:
getRoot("chmod -R 777 /data/data/com.xxxxx/databases/wa.db");
相关文章
- kotlin gson反序列化默认值失效深入讲解 12-28
- Android使用Volley框架定制PostUploadRequest上传文件 12-26
- Android使用Volley实现上传文件功能 12-26
- Android自定义控件仿iOS滑块SwitchButton 12-26
- Android自定义控件实现带数值和动画的圆形进度条 12-25
- Android自定义控件实现折线图 12-25