Fix Cursor warnings
This commit is contained in:
parent
0198c99a1c
commit
1d6e475eb5
|
@ -60,11 +60,11 @@ public class CallLogHelper {
|
||||||
try (Cursor cursor = context.getContentResolver()
|
try (Cursor cursor = context.getContentResolver()
|
||||||
.query(uri, QUERY_PROJECTION, selection, selectionArgs, sortOrder)) {
|
.query(uri, QUERY_PROJECTION, selection, selectionArgs, sortOrder)) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
int idIndex = cursor.getColumnIndex(CallLog.Calls._ID);
|
int idIndex = cursor.getColumnIndexOrThrow(CallLog.Calls._ID);
|
||||||
int typeIndex = cursor.getColumnIndex(CallLog.Calls.TYPE);
|
int typeIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.TYPE);
|
||||||
int numberIndex = cursor.getColumnIndex(CallLog.Calls.NUMBER);
|
int numberIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.NUMBER);
|
||||||
int dateIndex = cursor.getColumnIndex(CallLog.Calls.DATE);
|
int dateIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.DATE);
|
||||||
int durationIndex = cursor.getColumnIndex(CallLog.Calls.DURATION);
|
int durationIndex = cursor.getColumnIndexOrThrow(CallLog.Calls.DURATION);
|
||||||
|
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
long id = cursor.getLong(idIndex);
|
long id = cursor.getLong(idIndex);
|
||||||
|
|
|
@ -27,9 +27,9 @@ public class ContactsHelper {
|
||||||
try (Cursor cursor = resolver.query(uri, PROJECTION, null, null, null)) {
|
try (Cursor cursor = resolver.query(uri, PROJECTION, null, null, null)) {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
ContactItem contact = new ContactItem(
|
ContactItem contact = new ContactItem(
|
||||||
cursor.getLong(cursor.getColumnIndex(
|
cursor.getLong(cursor.getColumnIndexOrThrow(
|
||||||
ContactsContract.Contacts._ID)),
|
ContactsContract.Contacts._ID)),
|
||||||
cursor.getString(cursor.getColumnIndex(
|
cursor.getString(cursor.getColumnIndexOrThrow(
|
||||||
ContactsContract.Contacts.DISPLAY_NAME))
|
ContactsContract.Contacts.DISPLAY_NAME))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue