From 1d6e475eb592138468b40565e91df4b41785d1b6 Mon Sep 17 00:00:00 2001 From: xynngh Date: Sat, 31 Jul 2021 21:14:56 +0400 Subject: [PATCH] Fix Cursor warnings --- .../yetanothercallblocker/data/CallLogHelper.java | 10 +++++----- .../yetanothercallblocker/data/ContactsHelper.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/dummydomain/yetanothercallblocker/data/CallLogHelper.java b/app/src/main/java/dummydomain/yetanothercallblocker/data/CallLogHelper.java index a3ad8b2..555ad29 100644 --- a/app/src/main/java/dummydomain/yetanothercallblocker/data/CallLogHelper.java +++ b/app/src/main/java/dummydomain/yetanothercallblocker/data/CallLogHelper.java @@ -60,11 +60,11 @@ public class CallLogHelper { try (Cursor cursor = context.getContentResolver() .query(uri, QUERY_PROJECTION, selection, selectionArgs, sortOrder)) { if (cursor != null) { - int idIndex = cursor.getColumnIndex(CallLog.Calls._ID); - int typeIndex = cursor.getColumnIndex(CallLog.Calls.TYPE); - int numberIndex = cursor.getColumnIndex(CallLog.Calls.NUMBER); - int dateIndex = cursor.getColumnIndex(CallLog.Calls.DATE); - int durationIndex = cursor.getColumnIndex(CallLog.Calls.DURATION); + int idIndex = cursor.getColumnIndexOrThrow(CallLog.Calls._ID); + int typeIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.TYPE); + int numberIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER); + int dateIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.DATE); + int durationIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.DURATION); while (cursor.moveToNext()) { long id = cursor.getLong(idIndex); diff --git a/app/src/main/java/dummydomain/yetanothercallblocker/data/ContactsHelper.java b/app/src/main/java/dummydomain/yetanothercallblocker/data/ContactsHelper.java index 789e4b4..df10791 100644 --- a/app/src/main/java/dummydomain/yetanothercallblocker/data/ContactsHelper.java +++ b/app/src/main/java/dummydomain/yetanothercallblocker/data/ContactsHelper.java @@ -27,9 +27,9 @@ public class ContactsHelper { try (Cursor cursor = resolver.query(uri, PROJECTION, null, null, null)) { if (cursor != null && cursor.moveToFirst()) { ContactItem contact = new ContactItem( - cursor.getLong(cursor.getColumnIndex( + cursor.getLong(cursor.getColumnIndexOrThrow( ContactsContract.Contacts._ID)), - cursor.getString(cursor.getColumnIndex( + cursor.getString(cursor.getColumnIndexOrThrow( ContactsContract.Contacts.DISPLAY_NAME)) );