Android内部存储改变读取权限的方法
更新时间:2018年08月01日 09:13:00 作者:chaoyu168
今天小编就为大家分享一篇Android内部存储改变读取权限的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
在开发时,手机先要ROOT,然后在通过代码改变权限。
<span style="color:#330033;">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("exit\n");
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;
}</span>
引用时需要注意加入权限:
getRoot("chmod -R 777 /data/data/com.xxxxx/databases/wa.db");
以上这篇Android内部存储改变读取权限的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
鸿蒙手机版JNI实战案例解析(JNI开发、SO库生成、SO库使用)
这篇文章主要介绍了鸿蒙手机版JNI实战(JNI开发、SO库生成、SO库使用)的相关资料,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2021-04-04


最新评论