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
@@ -270,23 +270,18 @@ public class WidgetConversationProvider extends BaseWidgetProvider {
return null;
}
final Uri uri = MessagingContentProvider.buildConversationMetadataUri(conversationId);
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri,
ConversationListItemData.PROJECTION,
null, // selection
null, // selection args
null); // sort order
try (Cursor cursor = context.getContentResolver().query(uri,
ConversationListItemData.PROJECTION,
null, // selection
null, // selection args
null // sort order
)) {
if (cursor != null && cursor.getCount() > 0) {
final ConversationListItemData conv = new ConversationListItemData();
cursor.moveToFirst();
conv.bind(cursor);
return conv;
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return null;
}