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,753
  • 72
  • 57
  • 129
Rudi
  • 4,304
  • 4
  • 34
  • 44

0 Answers0