Created
September 24, 2023 20:41
-
-
Save HasibPrince/fa503633e63bde8a4facd390f4964a33 to your computer and use it in GitHub Desktop.
Usage of MediaStore API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val contentResolver = this.contentResolver | |
val contentValues = ContentValues().apply { | |
put(MediaStore.MediaColumns.DISPLAY_NAME, "applounge") | |
put(MediaStore.MediaColumns.MIME_TYPE, "text/plain") | |
put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS) | |
} | |
val uri = contentResolver.insert(MediaStore.Files.getContentUri("external"), contentValues) | |
uri?.let { | |
contentResolver.openOutputStream(it)?.use { outputStream -> | |
outputStream.write(fullMessage.toByteArray()) | |
outputStream.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment