Messaging: Use try-with-resource

Change-Id: I6649517cbd990502dfcb54f078764cf05f210268
This commit is contained in:
Michael W
2024-12-16 19:10:56 +01:00
parent 2a09fa3cb9
commit 9538179c75
24 changed files with 199 additions and 455 deletions

View File

@@ -601,18 +601,12 @@ public class BugleApnSettingsLoader implements ApnSettingsLoader {
*/
public static String getFirstTryApn(final SQLiteDatabase database, final String mccMnc) {
String key = null;
Cursor cursor = null;
try {
cursor = queryLocalDatabase(database, mccMnc, null/*apnName*/);
try (Cursor cursor = queryLocalDatabase(database, mccMnc, null/*apnName*/)) {
if (cursor.moveToFirst()) {
key = cursor.getString(ApnDatabase.COLUMN_ID);
}
} catch (final Exception e) {
// Nothing to do
} finally {
if (cursor != null) {
cursor.close();
}
}
return key;
}