File.delete()不会删除Android上的符号链接?

问题描述:

我无法删除Android上的符号链接。我不能File.delete()和既不符合 exec("rm " + verFile.getPath())File.delete()不会删除Android上的符号链接?

有一个符号

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"); } 

我可以

verFile.delete() 

更换

Runtime.getRuntime().exec("rm " + verFile.getPath()); 

,但它没有任何效果(该文件仍然不会被删除)。

亚行logcat我可以看到

W/MyApp (13298): Deleting file /data/data/com.example.app/mydata/12345.ver 
W/MyApp (13298): File exists! 

但文件12345.ver仍然存在!它具有与应用程序的其余部分相同的用户/组权限(lib目录由system用户拥有)。

任何线索?

+1

您是否在exec调用中尝试过'rm -f'? – 2010-11-19 16:30:03

我知道这有点晚,但谷歌送我到这里,同时试图解决类似的问题。 任何试图删除一个特定的符号链接失败的消息与混乱的消息“目录不为空” 我挖了一点深,发现目标文件不存在。我创建了一个,然后rm工作:-)。

对我来说似乎是Android中的一个错误,但我对Android确实太陌生了。