Skip to content

Instantly share code, notes, and snippets.

@jakubczaplicki
Created February 17, 2018 22:46
Show Gist options
  • Save jakubczaplicki/6b9ee2f6390ae088f267b4fbc361207e to your computer and use it in GitHub Desktop.
Save jakubczaplicki/6b9ee2f6390ae088f267b4fbc361207e to your computer and use it in GitHub Desktop.
storeImageToExternalStorage
private fun storeImageToExternalStorage(imageData: String, personIdentityId: String) {
// TODO: refactor to add base64 string to the cached JSON
val offendersFile = File(mView?.getContext()?.filesDir, personIdentityId+".jpg")
if (offendersFile.exists()) offendersFile.delete()
offendersFile.createNewFile()
val outputStream = mView?.getContext()?.openFileOutput(
personIdentityId+".jpg",
Context.MODE_PRIVATE
)
val decodedString = Base64.decode(imageData, Base64.DEFAULT)
outputStream?.write(decodedString)
outputStream?.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment