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,17 +1103,16 @@ fun Context.deleteSmsDraft(threadId: Long) {
|
||||||
val projection = arrayOf(Sms._ID)
|
val projection = arrayOf(Sms._ID)
|
||||||
val selection = "${Sms.THREAD_ID} = ?"
|
val selection = "${Sms.THREAD_ID} = ?"
|
||||||
val selectionArgs = arrayOf(threadId.toString())
|
val selectionArgs = arrayOf(threadId.toString())
|
||||||
try {
|
queryCursor(
|
||||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
uri = uri,
|
||||||
cursor?.use {
|
projection = projection,
|
||||||
while (cursor.moveToNext()) {
|
selection = selection,
|
||||||
val draftId = cursor.getLong(0)
|
selectionArgs = selectionArgs,
|
||||||
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
|
showErrors = true
|
||||||
contentResolver.delete(draftUri, null, null)
|
) { cursor ->
|
||||||
}
|
val draftId = cursor.getLongValue(Sms._ID)
|
||||||
}
|
val draftUri = Uri.withAppendedPath(Sms.CONTENT_URI, "/${draftId}")
|
||||||
} catch (e: Exception) {
|
contentResolver.delete(draftUri, null, null)
|
||||||
showErrorToast(e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue