Pradip Tilala
Pradip Tilala

Reputation: 1813

File does not exist error while creating zip file from audio files on Android 10 Q

Error description:

File does not exist: content:/com.alphainventor.filemanager.fileprovider/root/storage/emulated/0/Bollywood%20Mix/Old/Audio.mp3

I am using below dependency to create zip file:

implementation 'net.lingala.zip4j:zip4j:2.9.0'

Code used is as below:

fun zipAudios(context: Context, fileUrls: ArrayList<String>): File? {

        val zipfileCreated = createFile(
            getOutputDirectory(context),
            "yyyy-MM-dd-HH-mm-ss-SSS",
            ".zip"
        )

        // Create a buffer for reading the files
        try {
            // create the ZIP file
            val zipfile = ZipFile(zipfileCreated, null)

            for (i in fileUrls.indices) {
                zipfile.addFile(File(fileUrls[i]))
            }

            return zipfile.file
        } catch (ex: IOException) {
            System.err.println(ex.message)
        }
        return null
    }
  1. My App is selecting the audio from device using any available selector App and save its URL to play it.
  2. Audio file are able to play using MediaPlayer but I am not able to access it while creating .zip file for these audio files.

I have some questions regarding the same:

  1. Our URL has content URL format with selector App provider prefix like content:/com.alphainventor.filemanager.fileprovider/root/storage/emulated/0/Bollywood%20Mix/Old/Audio.mp3 How can I access such audio files and create zip from it on Android 10 programatically?

Upvotes: 0

Views: 2750

Answers (0)

Related Questions