I tried this Kotlin code to save a text file in external storage:
try {
var filePath = Environment.getExternalStorageState() + File.separator + "Text.txt"
var file = File(filePath)
file.createNewFile()
var fileWriter = FileWriter(file.path)
fileWriter.write("My Name Is Amirhosein")
fileWriter.close()
}
catch (ex: Exception) {
Toast.makeText(this,ex.message,Toast.LENGTH_LONG).show()
}
and this exception came in Toast:
No such file or directory
anyone knows how to fix it?