Checked with stackoverflow site as well. apparently, there is not way,
currently, to qury a row in which you have both, ID, DISPLAY_NAME and
PICTURE_URI.
It wont help anyway since i wanted to use it for the adapter, and if
the image uri points to null or is null itself i'll get an exception,
so i have to other override bindView or newView().

On Apr 8, 6:56 pm, poohtbear <[email protected]> wrote:
> I want to write a short app for getting some info from contacts, the
> first list screen i have should display the user Image (or an Image
> from resources if no such  image exists) an the user display name.
>
> The problem is i don't seem to find a query that will provide me with
> the display name and a user id AND the image URI in the same query.
> moreover I'm aware of the fact that if the user has no image and the
> URI is empty or null i will most likely to get an exception while the
> adapter calls setViewImage().
>
> Is there a simple way around it or should i override the
> setViewImage() or bindView() methods ?
>
> Also about the query , any chance i can make a single query for
> contact URI, _ID, contact_id and display name ?
>
> my current queries:
> To get the contacts :
> private Cursor getContacts() {
>         Uri uri = ContactsContract.Data.CONTENT_URI;
>         String[] projection =  new String[]
> {ContactsContract.Data._ID,ContactsContract.Data.CONTACT_ID,
> ContactsContract.Data.DISPLAY_NAME };
>         String selection = ContactsContract.Data.MIMETYPE + " = ?";
>         String[] selectionArgs =
> {ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE};
>         String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + "
> ASC";
>         return managedQuery(uri, projection, selection, selectionArgs,
> sortOrder);
>     }
>
> if i have a contact id and want the image:
> int _id = m_cursor.getColumnIndex(ContactsContract.Contacts._ID);
>                 //try to retrieve the photo, if exists.
>                 Uri photoUri =
> ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,
> m_cursor.getLong(_id));
>                 InputStream is =
> ContactsContract.Contacts.openContactPhotoInputStream(m_context.getContentResolver(),
> photoUri);
>
> here i get from a cursor with _ID column the id and then creating the
> uri, i know i can get a row number but i'm not familiar enough with
> contentProvider to know how to join tables to get it all in one query
> (if even possible).

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to