在开发时,手机先要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");



更多相关文章

  1. 使用TensorFlow在Android上进行物体检测
  2. android调用照相机拍照获取照片并做简单剪裁
  3. Android中webview拨打加载网页中的电话超链接
  4. ubuntu添加android真机调试
  5. Android中的GalleryView实例演示-周末福利有美女图
  6. 《Android第一行代码》first reading 十一
  7. Android(安卓)7.0 系统解决拍照的问题 exposed beyond app throu
  8. vue判断手机类型是安卓、微信或IOS
  9. Android两种 旋转Bitmap方法

随机推荐

  1. Android启动过程 && Activity生命周期 &&
  2. android.hardware.Camera翻译
  3. Android 4.2 BT系统之蓝牙关闭过程全跟踪
  4. 多方向抽屉效果
  5. OpenCV 连接 Android IP摄像头
  6. Android非主线程更新UI
  7. Android 获取地理位置的经度和纬度(zz)
  8. Android 高通代码预制apk可卸载,恢复出厂
  9. Unity 调用 Android Native 方法(一) 获
  10. android 建议在onPause和onStop处理的事