Messaging: Use try-with-resource

Change-Id: I6649517cbd990502dfcb54f078764cf05f210268
This commit is contained in:
Michael W
2024-12-26 15:54:37 +01:00
parent 2a09fa3cb9
commit 9538179c75
24 changed files with 199 additions and 455 deletions
@@ -148,13 +148,11 @@ public class DeleteConversationAction extends Action implements Parcelable {
Assert.notNull(conversationId);
final List<Uri> messageUris = new ArrayList<>();
Cursor cursor = null;
try {
cursor = db.query(DatabaseHelper.MESSAGES_TABLE,
new String[] { MessageColumns.SMS_MESSAGE_URI },
MessageColumns.CONVERSATION_ID + "=?",
new String[] { conversationId },
null, null, null);
try (Cursor cursor = db.query(DatabaseHelper.MESSAGES_TABLE,
new String[]{MessageColumns.SMS_MESSAGE_URI},
MessageColumns.CONVERSATION_ID + "=?",
new String[]{conversationId},
null, null, null)) {
while (cursor.moveToNext()) {
String messageUri = cursor.getString(0);
try {
@@ -164,10 +162,6 @@ public class DeleteConversationAction extends Action implements Parcelable {
+ messageUri);
}
}
} finally {
if (cursor != null) {
cursor.close();
}
}
for (Uri messageUri : messageUris) {
int count = MmsUtils.deleteMessage(messageUri);