From b239c7c1a2cb5ed0759711e9227ab48aa7952d62 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 9 Mar 2019 12:07:19 +0100 Subject: [PATCH] fix #264, properly handle notes synced to SD card files --- .../notes/pro/activities/MainActivity.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index abb4e277..42cea30c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -568,9 +568,11 @@ class MainActivity : SimpleActivity() { if (needsStupidWritePermissions(path)) { handleSAFDialog(path) { - var document = getDocumentFile(File(path).parent) ?: return@handleSAFDialog - if (!File(path).exists()) { - document = document.createFile("", path.getFilenameFromPath())!! + val document = if (File(path).exists()) { + getDocumentFile(path) ?: return@handleSAFDialog + } else { + val parent = getDocumentFile(File(path).parent) ?: return@handleSAFDialog + parent.createFile("", path.getFilenameFromPath())!! } contentResolver.openOutputStream(document.uri).apply {