您的位置:首页 > 移动开发 > Android开发

Android内部存储改变读取权限

2016-01-18 16:41 447 查看
在开发时,手机先要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");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: