I got one image file from Internal Storage, example name of file is name_image_old, i want rename become name_image_new. i have tried use function renameTO() but not working. My code:
private fun rename(from: File, to: File): Boolean {
return from.parentFile.exists() && from.exists() && from.renameTo(to)
}
val currentFile = File("/sdcard/currentFile.txt")
val newFile = File("/sdcard/newFile.txt")
if (rename(currentFile, newFile)) {
//Success
Log.i(TAG, "Success")
} else {
//Fail
Log.i(TAG, "Fail")
}