Created
February 17, 2018 22:46
-
-
Save jakubczaplicki/6b9ee2f6390ae088f267b4fbc361207e to your computer and use it in GitHub Desktop.
storeImageToExternalStorage
This file contains 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
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