catching an exception thrown at creating file outputstream

This commit is contained in:
tibbi 2019-12-17 17:41:49 +01:00
parent e9c00d186d
commit 8c07c451bd
2 changed files with 8 additions and 3 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.20.13'
propVersionName = '5.21.0'
kotlin_version = '1.3.61'
}

View file

@ -702,8 +702,13 @@ fun BaseSimpleActivity.getFileOutputStreamSync(path: String, mimeType: String, p
return null
}
val newDocument = documentFile.createFile(mimeType, path.getFilenameFromPath())
applicationContext.contentResolver.openOutputStream(newDocument!!.uri)
try {
val newDocument = documentFile.createFile(mimeType, path.getFilenameFromPath())
applicationContext.contentResolver.openOutputStream(newDocument!!.uri)
} catch (e: Exception) {
showErrorToast(e)
null
}
} else {
if (targetFile.parentFile?.exists() == false) {
targetFile.parentFile.mkdirs()