当前位置: 代码迷 >> Android >> App能否得到/data下的文件删除权限,该如何处理
  详细解决方案

App能否得到/data下的文件删除权限,该如何处理

热度:182   发布时间:2016-05-01 22:28:11.0
App能否得到/data下的文件删除权限
Hi all,

我的程序要删除/data下的某个文件,但是提示permission denied
是否有办法让我的app得到/data下的删除权限?

Thanks in advance

------解决方案--------------------
adb shell 进入android系统,修改权限 .............烂招.

------解决方案--------------------
我也来支烂招...
Java code
        String command = "rm /data/***";  // the command that will be execute            Runtime runtime = Runtime.getRuntime();              Process proc = null;                    try {            proc = runtime.exec(command);        } catch (IOException e1) {            e1.printStackTrace();        }                // put a BufferedReader on the ps output             InputStream inputstream = proc.getInputStream();        InputStreamReader inputstreamreader = new InputStreamReader(inputstream);            BufferedReader bufferedreader = new BufferedReader(inputstreamreader);                    // read the ps output and show it to screen.        ...        ...        // judge the return value                 try {                if (proc.waitFor() != 0) {                    System.err.println("exit value = " + proc.exitValue());                }             }            catch (InterruptedException e) {            System.err.println(e);        }
------解决方案--------------------
rm的话只用第一个try和最后一个try里面的就可以了,中间的可以不要
------解决方案--------------------
data目录除非你是root或者system用户组,要不是无法执行的。

即使你加上了 WRITE_INTERNAL_MEMORY也是不可以的。

最重要的是你是用sdk来开发三方软件,似乎无解。
------解决方案--------------------
删不了,除非adb shell
------解决方案--------------------
基本的linux知识,应用程序只是普通用户,没有那么高的权限,不可能的事情不要想了。
app可以在自己的目录里作事情,context有getfile之类的方法可以获取私有目录。
------解决方案--------------------
所以得进系统把权限改了啊。我一早就说过了,
  相关解决方案