Skip to content

Instantly share code, notes, and snippets.

@PetkevichPavel
Created August 24, 2019 08:37
Show Gist options
  • Save PetkevichPavel/2e84813659f4eae0b2ca891931a4c87f to your computer and use it in GitHub Desktop.
Save PetkevichPavel/2e84813659f4eae0b2ca891931a4c87f to your computer and use it in GitHub Desktop.
AN_Cloud Function: Class for File extension functions.
/**
* Context extension function which will save the file into the device local storage.
* @param data - content of the file.
* @param fileName - name of the final file.
*/
fun Context.saveFile(data: ByteArray, fileName: String) =
openFileOutput(fileName, Context.MODE_PRIVATE)?.apply {
write(data)
close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment