读/写文件,内部存储(android studio-java)

时间:2017-07-03 20:30:55

标签: java android internal-storage

我在路径 “/ data / data / 1 /” 上的内部存储上有一个文件夹,我的手机是 root 我有SuperUser和 我可以通过手机的文件管理器 查看和编辑它,但我无权从我的文件管理器访问此文件app,我的代码:

try {
            java.lang.Process p0 = Runtime.getRuntime().exec("su");
Toast.makeText(getApplicationContext(), "root" , Toast.LENGTH_SHORT).show();}
catch(Exception e){
Toast.makeText(getApplicationContext(), "not root" , Toast.LENGTH_SHORT).show();}

            File root0 = new File("/data/data/1/");
            File dir = new File(root0.getAbsolutePath());

if (dir.exists()){
    Toast.makeText(getApplicationContext(), "exist", Toast.LENGTH_SHORT).show();
if (dir.canRead()){
    Toast.makeText(getApplicationContext(), "read" , Toast.LENGTH_SHORT).show();}
else {
    Toast.makeText(getApplicationContext(), "not read", Toast.LENGTH_SHORT).show();}
if (dir.canWrite()) {
    Toast.makeText(getApplicationContext(), "write", Toast.LENGTH_SHORT).show();}
else {
    Toast.makeText(getApplicationContext(), "not write", Toast.LENGTH_SHORT).show();}
}catch(Exception e){
            Toast.makeText(getApplicationContext(), "no exist", Toast.LENGTH_SHORT).show();}

当我运行时,应用说: root,存在,不读,不写 ,请告诉我怎样才能让这个文件夹读/写?< / p>

0 个答案:

没有答案