Android column ‘_id’ does not exists Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Android column ‘_id’ does not exists without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Previously I selected everything by putting a null, but i get an error complaining that it has too many rows, so I’m trying to get a projection of the display name, contact id and phone number but getting the following error: “column ‘_id’ does not exist”

Here’s the code:

final String[] projection = { ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
            ContactsContract.CommonDataKinds.Phone.NUMBER,ContactsContract.CommonDataKinds.Phone.CONTACT_ID };

    Cursor cur = cr.query(
            ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection,
            "LENGTH(" + ContactsContract.CommonDataKinds.Phone.NUMBER
                    + ") >= 8 ) GROUP BY ("
                    + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, null,
            sortOrder);

But the error points to this line in my customadapter

super(context, layout, c, from, to);

Need help! Thanks!

Answer

Add BaseColumns._ID to your projection array.

We are here to answer your question about Android column ‘_id’ does not exists - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji