Я создаю android приложение и использую Firebase. Когда я пытаюсь загрузить данные из firebase в моем приложении android, отображается ошибка AsyncTask # 1. Я новичок ie в этой области и пытаюсь освоить основы android разработки. Вот код
inner class DownloadFileFromURL : AsyncTask<String?, String?, String?>() {
override fun doInBackground(vararg p0: String?): String? {
//file download path
val downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString()
//image download url
val url = URL(p0[0])
val filename=p0[1].toString()
val conection = url.openConnection()
conection.connect()
// input stream to read file - with 8k buffer
val input = BufferedInputStream(url.openStream(), 8192)
// output stream to write file
val output = FileOutputStream(downloadFolder + "/$filename")
val data = ByteArray(1024)
var total = 0L
// writing data to file
var count : Int
while (input.read(data).also { count = it } != -1) {
total += count.toLong()
output.write(data, 0, count)
}
// flushing output
output.flush()
// closing streams
output.close()
input.close()
return null
}
override fun onPostExecute(result: String?) {
super.onPostExecute(result)
Toast.makeText(this@FileListScreen,"File Downloaded",Toast.LENGTH_LONG).show()
}
}
Пожалуйста, предложите мне возможные решения этой ошибки