Skip to content

Commit b239c7c

Browse files
committed
fix #264, properly handle notes synced to SD card files
1 parent 7b1e0a5 commit b239c7c

File tree

1 file changed

+5
-3
lines changed
  • app/src/main/kotlin/com/simplemobiletools/notes/pro/activities

1 file changed

+5
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,11 @@ class MainActivity : SimpleActivity() {
568568

569569
if (needsStupidWritePermissions(path)) {
570570
handleSAFDialog(path) {
571-
var document = getDocumentFile(File(path).parent) ?: return@handleSAFDialog
572-
if (!File(path).exists()) {
573-
document = document.createFile("", path.getFilenameFromPath())!!
571+
val document = if (File(path).exists()) {
572+
getDocumentFile(path) ?: return@handleSAFDialog
573+
} else {
574+
val parent = getDocumentFile(File(path).parent) ?: return@handleSAFDialog
575+
parent.createFile("", path.getFilenameFromPath())!!
574576
}
575577

576578
contentResolver.openOutputStream(document.uri).apply {

0 commit comments

Comments
 (0)