I am trying to write a file to external storage, I don't know whats wrong with my code. It doesn't produce any exception, run normally, but there no file created in the Android/data directory.
I do have external storage write permission.
val fileDir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)
val file = File(fileDir, "test.txt")
val fos = FileOutputStream(file)
val data = "hello, world".toByteArray()
fos.write(data)
fos.close()
Am I doing something wrong here?