Rud*_*udi 5 file-io android delete-file
我正在使用以下代码在Android中重命名文件:
File source = new File(SOURCE_PATH);
File destination = new File(DESTINATION_PATH);
if (!destination.exists()) {
source.renameTo(destination);
}
Run Code Online (Sandbox Code Playgroud)
问题是重命名文件后,源文件夹中仍有一个包含0字节的旧名称的文件.
我添加了下面的行来删除文件:
if (source.exists()) {
source.delete();
}
Run Code Online (Sandbox Code Playgroud)
但结果保持不变.我该怎么办?