반응형
SMALL
내장메모리/Download 영역에 txt 파일 저장
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val contentValues = ContentValues()
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName)
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "text/plain")
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, "Download")
val resolver = contentResolver
val uri = resolver.insert(MediaStore.Files.getContentUri("external"), contentValues)
try {
val writeFile = "안드로이드"
resolver.openOutputStream(uri!!)!!.write(writeFile.toByteArray())
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
반응형
LIST
'AOS - Kotlin' 카테고리의 다른 글
[android/kotlin] play game 로그인 하기 (0) | 2024.09.30 |
---|---|
[android] 애드몹 전면 광고 스킵 버튼 뜨지 않는 문제 (0) | 2024.05.13 |
[android/kotlin] base64 string > pdf 변환 후 파일 저장 (0) | 2024.04.05 |
[android/kotlin] handler 데이터 여러개 전달하기 (0) | 2024.04.05 |
[android/kotlin] apk 이름 변경 (0) | 2024.03.11 |