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?
source
share