From 52a38e4dc17c4ce61383e3b227ad4330b32ae59d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 2 Jul 2022 15:02:39 +0200 Subject: [PATCH] fix deleting files on Android 10 --- .../voicerecorder/adapters/RecordingsAdapter.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt index 0e5bb72..3e018ef 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt @@ -175,7 +175,13 @@ class RecordingsAdapter( val uri = Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) val selection = "${Media._ID} = ?" val selectionArgs = arrayOf(it.id.toString()) - activity.contentResolver.delete(uri, selection, selectionArgs) + val result = activity.contentResolver.delete(uri, selection, selectionArgs) + + if (result == 0) { + recordingsToRemove.forEach { + activity.deleteFile(File(it.path).toFileDirItem(activity)) + } + } } doDeleteAnimation(oldRecordingIndex, recordingsToRemove, positions) }