Note that there are some explanatory texts on larger screens.

plurals
  1. POcant read phone contacts
    primarykey
    data
    text
    <p>I am reading contacts stored in phone and showing them in list view. My code is as follows:</p> <pre><code>String col[]={ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME}; Cursor cursorNames = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, col, null, null, null); intentContactsToreturn=new Intent(); ArrayList&lt;String&gt; contactNames=new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; contactNumbers=new ArrayList&lt;String&gt;(); try { if(cursorNames.getCount() &gt; 0) { while(cursorNames.moveToNext()) { String id = cursorNames.getString(cursorNames.getColumnIndex(Contacts._ID)); contactNames.add(cursorNames.getString(cursorNames.getColumnIndex(Contacts.DISPLAY_NAME))); Cursor cursorNumbers =getContentResolver().query(CommonDataKinds.Phone.CONTENT_URI, null, CommonDataKinds.Phone.CONTACT_ID +" = ?", new String[]{id}, null); cursorNumbers.moveToFirst(); contactNumbers.add(cursorNumbers.getString(cursorNumbers.getColumnIndex(CommonDataKinds.Phone.NUMBER))); } } } finally { cursorNames.close(); } ContactListArrayAdapter arrayAdapter = new ContactListArrayAdapter(this,contactNames,contactNumbers); // lv.addFooterView(b); listViewContacts.setAdapter(arrayAdapter); } </code></pre> <p>Now the problem it is reading the SIM contacts (and not phone contacts) also it is not reading all the contacts in SIM. </p> <p>It is reading some of the contacts in SIM and exact number is 15 (while in SiM there are 100+ contacts) and also it repeats the contacts in list view.</p> <p>like this </p> <p>15 contacts then again the same 15 contacts are reapeating in list view.</p> <p>again and again total 4 times 15 contacts are repeated.</p>
    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.
 

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