Android how to zip all file selected in one zip file

Viewed 28

I have one list all files. My code get all file in device, and select list some file i want to zip in 1 file zip. How to i can zip all file selected in one zip file ?

fun getAllDir(dir: File) {
        val listFile = dir.listFiles()
        if (listFile != null) {
            for (i in listFile.indices) {
                if (listFile[i].isDirectory) {
                    getAllDir(listFile[i])
                } else {
                    if (listFile[i].path.endsWith(".mp4")) {
                        listVideo.add(
                           
                            listFile[i]
                        )
                    }
                }
            }
        }
    }
1 Answers

If you want to zip or extract zip files you can use this zip4j library and check out its documentation it will help you https://github.com/srikanth-lingala/zip4j

You can also zip a single file and multiple files also using this library

Related