Skip to content

Instantly share code, notes, and snippets.

@virendersran01
Forked from HasibPrince/FileUtils.kt
Created September 30, 2023 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virendersran01/566c4319a85a42a3cc06b119f9eafb3a to your computer and use it in GitHub Desktop.
Save virendersran01/566c4319a85a42a3cc06b119f9eafb3a 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