What to do when - java.io.FileNotFoundException: No content provider? What to do when - java.io.FileNotFoundException: No content provider? android android

What to do when - java.io.FileNotFoundException: No content provider?


Maybe you should pass an uri of the form file:///sdcard/Video0006.mp4.


You can also try this:

Uri.fromFile(new File(your image path));


Method to save an bitmap to a file

  private fun bitmapToFile(bitmap:Bitmap): Uri {        // Get the context wrapper        val wrapper = ContextWrapper(applicationContext)        // Initialize a new file instance to save bitmap object        var file = wrapper.getDir("Images",Context.MODE_PRIVATE)        file = File(file,"${UUID.randomUUID()}.jpg")        try{            // Compress the bitmap and save in jpg format            val stream:OutputStream = FileOutputStream(file)            bitmap.compress(Bitmap.CompressFormat.JPEG,100,stream)            stream.flush()            stream.close()        }catch (e:IOException){            e.printStackTrace()        }        // Return the saved bitmap uri        return Uri.parse(file.absolutePath)    }