diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt index d3beb6e2..b0b08594 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -502,6 +502,7 @@ fun Context.deleteConversation(threadId: Long) { contentResolver.delete(uri, selection, selectionArgs) conversationsDB.deleteThreadId(threadId) + messagesDB.deleteThreadMessages(threadId) } fun Context.deleteMessage(id: Long, isMMS: Boolean) { @@ -510,6 +511,7 @@ fun Context.deleteMessage(id: Long, isMMS: Boolean) { val selectionArgs = arrayOf(id.toString()) try { contentResolver.delete(uri, selection, selectionArgs) + messagesDB.delete(id) } catch (e: Exception) { showErrorToast(e) } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/interfaces/MessagesDao.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/interfaces/MessagesDao.kt index 4e25bd99..70bf6510 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/interfaces/MessagesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/interfaces/MessagesDao.kt @@ -25,4 +25,10 @@ interface MessagesDao { @Query("UPDATE messages SET read = 1 WHERE thread_id = :threadId") fun markThreadRead(threadId: Long) + + @Query("DELETE FROM messages WHERE id = :id") + fun delete(id: Long) + + @Query("DELETE FROM messages WHERE thread_id = :threadId") + fun deleteThreadMessages(threadId: Long) }