5

I'm using the below code to rename a file in Android:

File source = new File(SOURCE_PATH);
File destination = new File(DESTINATION_PATH);

if (!destination.exists()) {
    source.renameTo(destination);
}

The problem is after renaming the file, there is still a file with the old name in the source folder containing 0 bytes.

I added the lines below to delete the file:

if (source.exists()) {
    source.delete();
}

But the result stays the same. What should I do?

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Rudi
  • 4,290
  • 4
  • 32
  • 43

0 Answers0