Use queryCursor extension for deleting drafts
This commit is contained in:
parent
757d849875
commit
be553f0b10
1 changed files with 10 additions and 11 deletions
|
|
@ -1103,18 +1103,17 @@ fun Context.deleteSmsDraft(threadId: Long) {
|
|||
val projection = arrayOf(Sms._ID)
|
||||
val selection = "${Sms.THREAD_ID} = ?"
|
||||
val selectionArgs = arrayOf(threadId.toString())
|
||||
try {
|
||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
while (cursor.moveToNext()) {
|
||||
val draftId = cursor.getLong(0)
|
||||
queryCursor(
|
||||
uri = uri,
|
||||
projection = projection,
|
||||
selection = selection,
|
||||
selectionArgs = selectionArgs,
|
||||
showErrors = true
|
||||
) { cursor ->
|
||||
val draftId = cursor.getLongValue(Sms._ID)
|
||||
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
|
||||
contentResolver.delete(draftUri, null, null)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.updateLastConversationMessage(threadId: Long) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue