操作 /data/data/pkg/ 下文件需要权限

来源:互联网 发布:camtasia studio7软件 编辑:程序博客网 时间:2024/06/13 05:57

方法一:

使用Context.openFileOutput(String name, int mode)创建文件,

mode 设为 MODE_WORLD_READABLE。

方法二:

你可以先把文件的权限修改下,在linux下修改权限是chmod,android里也一样,比如
chmod 777 /文件夹/文件名
直接运行下面的方法,参数就是你的命令:chmod 777 /文件夹/文件名

private boolean runCommand(String command) {       Process process = null;           try {               process = Runtime.getRuntime().exec(command);           Log.i("command","The Command is : "+command);               process.waitFor();           } catch (Exception e) {                   Log.w("Exception ", "Unexpected error - "+e.getMessage());                   return false;           } finally {                   try {                           process.destroy();                   } catch (Exception e) {                           Log.w("Exception ", "Unexpected error - "+e.getMessage());                   }           }           return true;   }



原创粉丝点击