【发布时间】:2010-11-19 15:49:27
【问题描述】:
我无法在 Android 上删除符号链接。不能使用File.delete() 也不能使用
exec("rm " + verFile.getPath())
我有一个符号链接
com.example.app/mydata/12345.ver --> com.example.app/lib/library.so
创建者
Runtime.getRuntime().exec(String.format("ln -s %s %s", target, link));
升级后(从网上下载不同的 build.apk)我想删除这个链接
File verFile = new File(dataDir, verFile);
Log.w("MyApp", "Deleting file " + verFile.getPath());
if (verFile.exists()) Log.w("MyApp", "File exists!");
try {
Runtime.getRuntime().exec("rm " + verFile.getPath());
} catch( IOException ioex ) { Log.w("MyApp", "Failed to delete"); }
我可以替换
Runtime.getRuntime().exec("rm " + verFile.getPath());
与
verFile.delete()
但它没有效果(文件仍然不会被删除)。
从adb logcat我可以看到
W/MyApp (13298): Deleting file /data/data/com.example.app/mydata/12345.ver
W/MyApp (13298): File exists!
但文件 12345.ver 仍然存在!它与应用程序的其余部分具有相同的用户/组权限(lib 目录除外,该目录归 system 用户所有)。
有什么线索吗?
【问题讨论】:
-
你在 exec 调用中试过 'rm -f' 吗?
标签: android