博客
关于我
Android内部存储改变读取权限
阅读量:502 次
发布时间:2019-03-07

本文共 1017 字,大约阅读时间需要 3 分钟。

在开发时,手机先要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("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;	    }
引用时需要注意加入权限:

getRoot("chmod -R 777 /data/data/com.xxxxx/databases/wa.db");

转载地址:http://xfpjz.baihongyu.com/

你可能感兴趣的文章
nginx实现负载均衡
查看>>
Nginx实现负载均衡时常用的分配服务器策略
查看>>
Nginx实现限流
查看>>
Nginx将https重定向为http进行访问的配置(附Demo)
查看>>
Nginx屏蔽电脑端访问,但不限制蜘蛛爬取
查看>>
nginx工作笔记004---配置https_ssl证书_视频服务器接口等
查看>>
nginx工作笔记005---nginx配置负载均衡_在微服务中实现网关集群_实现TCP传输层协议__http协议的负载均衡
查看>>
nginx常用命令及简单配置
查看>>