Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to access default contacts picture in my Android app
    primarykey
    data
    text
    <p>I am creating a contacts application for android, I have successfully created a list view of the contacts and also retrieved the contact images(for those contacts which has images) and the contacts which doesn't have any image shows without any image is displayed without any image. I need the contacts without any images to be displayed with the default contact silhouette image. Here is the code</p> <pre><code>private void populateContactList() { // TODO Auto-generated method stub // Build adapter with contact entries Cursor cursor = getContacts(); String[] fields = new String[] { ContactsContract.Data.DISPLAY_NAME, ContactsContract.Data.PHOTO_THUMBNAIL_URI }; adapter = new SimpleCursorAdapter(this, R.layout.contactentrylayout, cursor, fields, new int[] { R.id.contactEntryText, R.id.contactimageentry }); mContactList.setAdapter(adapter); } @SuppressWarnings("deprecation") private Cursor getContacts() { // TODO Auto-generated method stub // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Data.PHOTO_THUMBNAIL_URI }; // String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + // " = '" // + (mShowInvisible ? "0" : "1") + "'"; String selection = ContactsContract.Contacts.DISPLAY_NAME + " LIKE ? OR " + ContactsContract.Contacts.DISPLAY_NAME_ALTERNATIVE + " LIKE ?"; String[] selectionArgs = { etquery.getText().toString() + "%", etquery.getText().toString() + "%" }; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; return managedQuery(uri, projection, selection, selectionArgs, sortOrder); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload