Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did this before, May be this help you Out :</p> <p><strong>Following is Function For Getting Contact Number</strong></p> <pre><code>public void queryAllPhoneNumbersFromContacts(int contactId, List&lt;ListViewEntry&gt; content) { final String[] projection = new String[] { Phone.NUMBER, Phone.TYPE, }; final Cursor phone = managedQuery( Phone.CONTENT_URI, projection, Data.CONTACT_ID + "=?", new String[]{String.valueOf(contactId)}, null); if(phone.moveToFirst()) { final int contactNumberColumnIndex = phone.getColumnIndex(Phone.NUMBER); final int contactTypeColumnIndex = phone.getColumnIndex(Phone.TYPE); while(!phone.isAfterLast()) { final String number = phone.getString(contactNumberColumnIndex); final int type = phone.getInt(contactTypeColumnIndex); content.add(new ListViewEntry(number, Phone.getTypeLabelResource(type),R.string.type_phone)); phone.moveToNext(); } } phone.close(); } </code></pre> <p><strong>Following is Function For Getting Email-id</strong></p> <pre><code> public void queryAllEmailAddressesFromContacts(int contactId, List&lt;ListViewEntry&gt; content) { final String[] projection = new String[] { Email.DATA, // use Email.ADDRESS for API-Level 11+ Email.TYPE }; final Cursor email = managedQuery( Email.CONTENT_URI, projection, Data.CONTACT_ID + "=?", new String[]{String.valueOf(contactId)}, null); if(email.moveToFirst()) { final int contactEmailColumnIndex = email.getColumnIndex(Email.DATA); final int contactTypeColumnIndex = email.getColumnIndex(Email.TYPE); while(!email.isAfterLast()) { final String address = email.getString(contactEmailColumnIndex); final int type = email.getInt(contactTypeColumnIndex); content.add(new ListViewEntry(address, Email.getTypeLabelResource(type),R.string.type_email)); email.moveToNext(); } } email.close(); } </code></pre> <p><strong>string.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="type_phone"&gt;Phone Number&lt;/string&gt; &lt;string name="type_email"&gt;E-Mail&lt;/string&gt; &lt;/resources&gt; </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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