软件编程
位置:首页>> 软件编程>> Android编程>> Android内部存储改变读取权限的方法

Android内部存储改变读取权限的方法

作者:chaoyu168  发布时间:2021-09-05 13:04:40 

标签: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");

来源:https://blog.csdn.net/chaoyu168/article/details/50537646

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com