mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
make sure the file exists before trying to read it at the read activity
This commit is contained in:
@ -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() }
|
||||
|
Reference in New Issue
Block a user