'Writing a file to getExternalFilesDir not showing up in file manager

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?



Solution 1:[1]

The default file manager on my samsung mobile is not showing any data directory. I installed ZArchive file manager from Google play and it showing me all the files.

I am not going to delete this question, in-case someone come across the same issue as me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeeva