Here is the code i am tring to do the same when i am downloading anything from webView in android.
webview.setDownloadListener { url, userAgent, contentDisposition, mimetype, l ->
val request = DownloadManager.Request(Uri.parse(url))
request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype))
request.setDescription("Downloading file...")
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
var newuri=FileProvider.getUriForFile(context, "com.shyptsolution.classproject"+ ".provider", File(context.filesDir,"fileName"))
// request.setDestinationUri(newuri)
request.setDestinationInExternalPublicDir(
context.filesDir.absolutePath,
URLUtil.guessFileName(url, contentDisposition, mimetype)
)
val dm =context.applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
dm!!.enqueue(request)
}
But I am getting error in this that it is not a standard directory. How can I save the files in cache or filesdir??
I just want to see my files in the files
folder shown in the pic below.