make sure the file exists before trying to read it at the read activity

This commit is contained in:
tibbi
2018-03-31 10:38:13 +02:00
parent 90a0d6a663
commit 308755c5ba
3 changed files with 11 additions and 5 deletions

View File

@ -80,7 +80,13 @@ class ReadTextActivity : SimpleActivity() {
val text = if (uri.scheme == "file") {
filePath = uri.path
File(uri.path).readText()
val file = File(filePath)
if (file.exists()) {
file.readText()
} else {
toast(R.string.unknown_error_occurred)
""
}
} else {
try {
contentResolver.openInputStream(uri).bufferedReader().use { it.readText() }