No file generated on writing file

Viewed 16

Directory has been created but no file and neither toast or log. Testing directly trough USB. I search on all FS and no files that match

        val es = File(Environment.getExternalStorageDirectory().toString() + "/Notes")
        var success = true

        if (!es.exists())
            success = es.mkdir()

        if (success) {
            val sd = File(note.noteTitle + "-" + note.timeStamp)

            if (!sd.exists())
                success = sd.mkdir()

            if (success) {
                val dest = File(sd, note.noteTitle)

                PrintWriter(dest).use { out -> out.println(note.noteDescription) }
            }
        } else {
            Toast.makeText(this, "directory not created", Toast.LENGTH_SHORT).show()
        }
0 Answers
Related