Sunday, May 8, 2016

Invalid column deleted while trying to query a column

Leave a Comment

I am trying to execute the following query in my android app:

private static final String[] PROJECTION =             {                     Data.CONTACT_ID, Data.MIMETYPE,                     Data.DISPLAY_NAME, Phone.NUMBER,                     Phone.TYPE, StructuredName.GIVEN_NAME,                     StructuredName.MIDDLE_NAME,                     StructuredName.FAMILY_NAME,                     Data.DELETED             };   private static final String SELECTION = "(" + Data.MIMETYPE + " = ? AND "         + Phone.TYPE + " IN (?,?,?)) OR ("         + Data.MIMETYPE + " IN (?))";   private static final String[] SELECTION_ARGS =         {                 Phone.CONTENT_ITEM_TYPE,                 String.valueOf(Phone.TYPE_MOBILE),                 String.valueOf(Phone.TYPE_HOME),                 String.valueOf(Phone.TYPE_WORK),                 StructuredName.CONTENT_ITEM_TYPE         }; final Cursor cursor = mContext.getContentResolver().query(                 Data.CONTENT_URI, PROJECTION, SELECTION, SELECTION_ARGS, Data.CONTACT_ID); 

But I get the following error:

04-29 11:00:58.715  8588 15565 E DatabaseUtils: Writing exception to parcel 04-29 11:00:58.715  8588 15565 E  DatabaseUtils: java.lang.IllegalArgumentException: Invalid column deleted 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at android.database.sqlite.SQLiteQueryBuilder.computeProjection(SQLiteQueryBuilder.java:632) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at android.database.sqlite.SQLiteQueryBuilder.buildQuery(SQLiteQueryBuilder.java:447) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:387) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at com.android.providers.contacts.ContactsProvider2.doQuery(ContactsProvider2.java:6528) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at com.android.providers.contacts.ContactsProvider2.queryLocal(ContactsProvider2.java:6479) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at com.android.providers.contacts.ContactsProvider2.query(ContactsProvider2.java:5038) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at android.content.ContentProvider$Transport.query(ContentProvider.java:238) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112) 04-29 11:00:58.715  8588 15565 E  DatabaseUtils:  at android.os.Binder.execTransact(Binder.java:453) 

I want to know if the contact that I am reading is deleted or not, so the Data.DELETED column is needed for me and that seems to be causing the error. But when I checked the Android documentation, DELETED does seem to be a valid column to use with ContactsContract.Data.

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment