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)) );