Rename / Delete file leaves empty file

I use the code below 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 that after renaming the file, there is still a file with the old name in the original folder containing 0 bytes.

I added the lines below to delete the file:

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

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

+4
source share

Source: https://habr.com/ru/post/1527187/


All Articles