val root = getExternalFilesDir(null) val root2 = getExternalFilesDir(Environment.DIRECTORY_PICTURES) val root3 = getExternalFilesDir(Environment.DIRECTORY_MOVIES) Log.e("gggggg", "\n\n\n") Log.e("gggggg", root?.path ?: "") Log.e("gggggg", root2?.path ?: "") Log.e("gggggg", root3?.path ?: "") Log.e("gggggg", "\n\n\n") Log.e("gggggg", root?.absolutePath ?: "") Log.e("gggggg", root2?.absolutePath ?: "") Log.e("gggggg", root3?.absolutePath ?: "") root2?.let { val file = File(it.path, "ceshi.txt") if(!file.exists()){ file.createNewFile() } val outputStream = FileOutputStream(file) val b = "1234567788999".toByteArray() outputStream.write(b) outputStream.flush() outputStream.close() } val file1 = File(root2!!.path) if(file1.exists()){ Log.e("gggggg", "存在" + file1.path) }else{ Log.e("gggggg", "不存在" + file1.path) } val file = File(root2!!.path, "ceshi.txt") if(file.exists()){ Log.e("gggggg", "存在" + file.path) }else{ Log.e("gggggg", "不存在" + file.path) }