Android中遇到问题:file.delete()不能删除文件

Java code
   
   
   
   
public static void deleteFile(String localFileName) { // localFileName = localFileName.replace("\\", "/"); File localFile = new File(localFileName); boolean flag = false ; if (localFile.isFile() && localFile.exists()){ log.debug( " localFile-Path- " + localFile.getPath() + " Ab " + localFile.getAbsolutePath()); log.debug( " localFile-File- " + localFile + " Ab " + localFile.getAbsoluteFile()); log.debug( " localFileName-- " + localFileName); flag = localFile.getAbsoluteFile().delete(); } log.debug( " 文件 " + localFileName + " 是否删除成功: " + flag); }

API中关于getAbsoluteFile方法的说明:
public File getAbsoluteFile()返回此抽象路径名的绝对路径名形式。等同于 new File(this.getAbsolutePath())。 
返回:
绝对抽象路径名,它与此抽象路径名表示相同的文件或目录 
抛出: 
SecurityException - 如果无法访问所需的系统属性值。
从以下版本开始: 
1.2 

你可能感兴趣的:(java,android,String,api,File)