Is it possible to copy a folder present in sdcard to another folder present the same sdcard programmatically ??
If so, how to do that?
Kotlin code
fun File.copyFileTo(file: File) {
inputStream().use { input ->
file.outputStream().use { output ->
input.copyTo(output)
}
}
}
fun File.copyDirTo(dir: File) {
if (!dir.exists()) {
dir.mkdirs()
}
listFiles()?.forEach {
if (it.isDirectory) {
it.copyDirTo(File(dir, it.name))
} else {
it.copyFileTo(File(dir, it.name))
}
}
}