android下file.delete无法删除文件。
伊谢尔伦
伊谢尔伦 2017-04-17 11:56:43
0
3
784
    File file = new File("/data/data/com.wlanplus.chang/lib/libcutil.so");
    file.delete();

执行后查看文件依然在。 后来加入如下代码

upgradeRootPermission(getPackageCodePath());//请求ROOT权限
file.setExecutable(true, false);
file.setReadable(true, false);
file.setWritable(true, false);

添加了权限:

<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

依然不行。

file.exists() file.canWrite()返回也都是true。
该怎么才能删除呢?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
Ty80

Looking at the file path, it should be a problem with the file you want to delete. The system doesn’t want you to delete it, so it creates a new one every time you delete it. You can try manually deleting the file on your phone. If you still can't delete it, that's why.

左手右手慢动作

/data/data/+Package name If the files in the directory are non-root, only the package name program can perform read and write operations.

左手右手慢动作

You can refer to http://www.cnblogs.com/tgyf/p/4649319.html

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template