Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 731243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:00:15+00:00 2026-05-14T07:00:15+00:00

I couldn’t find a single query that would give me in API 2.0 of

  • 0

I couldn’t find a single query that would give me in API 2.0 of the contacts API the URI of the contact’s image and the display name.

For now as far as i know i can create a URI by having the contact’s _ID , but i didn’t see any row name that i can use in the projection of Data or Contact to get all that i need.

(i refer to using API 2 of the contacts API on android SDK V5 and above )

10x.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:00:16+00:00Added an answer on May 14, 2026 at 7:00 am

    This method returns the photo Uri or null if does not exists for a contact identified by getId()

    public Uri getPhotoUri() {
            Uri person = ContentUris.withAppendedId(
                    ContactsContract.Contacts.CONTENT_URI, Long.parseLong(getId()));
            Uri photo = Uri.withAppendedPath(person,
                    ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
    
            Cursor cur = this.ctx
                    .getContentResolver()
                    .query(
                            ContactsContract.Data.CONTENT_URI,
                            null,
                            ContactsContract.Data.CONTACT_ID
                                    + "="
                                    + this.getId()
                                    + " AND "
                                    + ContactsContract.Data.MIMETYPE
                                    + "='"
                                    + ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE
                                    + "'", null, null);
            if (cur != null) {
                if (!cur.moveToFirst()) {
                    return null; // no photo
                }
            } else {
                return null; // error in cursor process
            }
            return photo;
        }
    

    If you add a projection to the Cursor to return ContactsContract.Data.CONTACT_ID, and ContactsContract.Data.DISPLAY_NAME, probably you will end up having a list of contacts that have photo set. (not all of the contacts). Then for each contact you can compute the Uri of the photo like in the beginning of the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I couldn't find a suitable title for this. I'm going to express my query
I couldn't find anything that rejects or confirms whether SQL Server 'MONEY' data type
I couldn't figure out that from SASS documentation. For example I would like to
Couldn't find a trace of the source code behind the Photos application that runs
Couldn't find anything related to the subject in Zend Framework API. What is the
I couldn't find the answer to this in any other question. Suppose that I
Couldn't find an answer to this one. I have a WPF ListView control that
Couldn't find similar questions: I'm currently designing my app and after that I will
Couldn't find_if just be an overload of find ? That's how std::binary_search and friends
I couldn't find a straight answer to my question and need to know it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.