Writing a file to getExternalFilesDir not showing up in file manager

Viewed 114

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?

1 Answers

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.

Related