catch exceptions thrown at getting file output stream
This commit is contained in:
parent
43e2fe622f
commit
dc33ffeef5
2 changed files with 8 additions and 2 deletions
|
@ -6,7 +6,7 @@ buildscript {
|
|||
propMinSdkVersion = 16
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '3.8.11'
|
||||
propVersionName = '3.8.12'
|
||||
kotlin_version = '1.2.21'
|
||||
support_libs = '27.0.2'
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.simplemobiletools.commons.models.SharedTheme
|
|||
import com.simplemobiletools.commons.views.MyTextView
|
||||
import kotlinx.android.synthetic.main.dialog_title.view.*
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
import java.util.*
|
||||
|
@ -559,7 +560,12 @@ fun BaseSimpleActivity.getFileOutputStream(file: File, callback: (outputStream:
|
|||
}
|
||||
|
||||
if (document?.exists() == true) {
|
||||
callback(applicationContext.contentResolver.openOutputStream(document.uri))
|
||||
try {
|
||||
callback(applicationContext.contentResolver.openOutputStream(document.uri))
|
||||
} catch (e: FileNotFoundException) {
|
||||
showErrorToast(e)
|
||||
callback(null)
|
||||
}
|
||||
} else {
|
||||
val error = String.format(getString(R.string.could_not_create_file), file.absolutePath)
|
||||
showErrorToast(error)
|
||||
|
|
Loading…
Reference in a new issue