Skip to content

Instantly share code, notes, and snippets.

@HasibPrince
Created September 24, 2023 20:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HasibPrince/f533a861c1115b522f705cb38b8a367b to your computer and use it in GitHub Desktop.
Save HasibPrince/f533a861c1115b522f705cb38b8a367b to your computer and use it in GitHub Desktop.
Usage of old storage api
val filename = "myFile.txt"
val content = "Hello, World!"
val documentsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)
val file = File(documentsDir, filename)
file.outputStream().use { outputStream ->
outputStream.write(content.toByteArray())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment