Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun testGetFile(contentUri: String) : File? {
- val file = File(cacheDir, "img_${System.currentTimeMillis()}")
- try {
- file.createNewFile()
- } catch (ex: IOException) {
- Log.e("debug", "Error while file creation", ex)
- return file
- }
- val inputStream = contentResolver.openInputStream(Uri.parse(contentUri))
- val bytearray = inputStream.readBytes()
- val outputStream = FileOutputStream(file)
- outputStream.write(bytearray)
- return file
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement