I am getting
open failed:
EACCES (Permission denied)
on the line OutputStream myOutput = new FileOutputStream
To store a file in a directory
which is foreign to the app's directory is restricted above API 29+
. So to generate a new file or to create a new file use your application directory like this :-
So the correct approach is :-
val file = File(appContext.applicationInfo.dataDir + File.separator + "anyRandomFileName/")
You can write any data into this generated file !
The above file
is accessible and would not throw any exception
because it resides in your own developed app's directory.
The other option is android:requestLegacyExternalStorage="true"
in manifest application tag
as suggested by Uriel
but its not a permanent solution !