最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android内部存储改变读取权限的方法
时间:2022-06-25 22:50:23 编辑:袖梨 来源:一聚教程网
在开发时,手机先要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");
相关文章
- 淘宝官方论坛入口 - 2026最新版淘宝社区 06-11
- 光隙解语新手10连推荐 06-11
- NPC精神是什么 - 当代年轻人的社交状态解读 06-11
- 末世崛起钻石怎么获得 06-11
- 缤果盒子2026年最新招聘信息 - 全国热门岗位持续招聘中 06-11
- 大奉打更人职业体系有什么 06-11