Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>try with this dude :) best of luck</p> <pre><code> &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt; </code></pre> <p>and this is code of class</p> <pre><code>public class ReadContacts extends AsyncTask&lt;Void, Void, Void&gt;{ private ListView contactsList; private Context cntx; private Constant constants; static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { Contacts._ID, // 0 Contacts.DISPLAY_NAME, // 1 Contacts.STARRED, // 2 Contacts.TIMES_CONTACTED, // 3 Contacts.CONTACT_PRESENCE, // 4 Contacts.PHOTO_ID, // 5 Contacts.LOOKUP_KEY, // 6 Contacts.HAS_PHONE_NUMBER, // 7 }; private long contactId; private String display_name; private String phoneNumber; private ArrayList&lt;ContactsWrapper&gt;contactWrap = new ArrayList&lt;ContactsWrapper&gt;(); private HashMap&lt;Long, ArrayList&lt;ContactsWrapper&gt;&gt;map = new HashMap&lt;Long, ArrayList&lt;ContactsWrapper&gt;&gt;(); private ContactsAdapter adapter; private DataController controller; public ReadContacts(Context cntx, ListView contactList) { // TODO Auto-generated constructor stub this.cntx = cntx; constants = new Constant(); this.contactsList = contactList; controller = DataController.getInstance(); } @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); if(!(controller.contactWrapper.size()&gt;0)) constants.displayProgressDialog(cntx, "Loading Contacts...", "Please Wait"); } @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub if(!(controller.contactWrapper.size()&gt;0)) { try { String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.HAS_PHONE_NUMBER + "=1) AND (" + Contacts.DISPLAY_NAME + " != '' ))"; Cursor c = cntx.getContentResolver().query(Contacts.CONTENT_URI, CONTACTS_SUMMARY_PROJECTION, select, null, Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); int colorcounter = 0; String[] colorcounter_array = { "#91A46B", "#8BB6B5", "#CAA973", "#8DA6C8","#D19B8D"}; int color_string; for(int i=0;i&lt;c.getCount();i++) { // contactWrap.clear(); try { contactId = 0; String hasPhone = ""; display_name = ""; phoneNumber = ""; c.moveToPosition(i); contactId = c.getLong(0); display_name = c.getString(1); hasPhone = c.getString(7); if (hasPhone.equalsIgnoreCase("1")) hasPhone = "true"; else hasPhone = "false" ; if (Boolean.parseBoolean(hasPhone)) { Cursor phones = cntx.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,null, null); while (phones.moveToNext()) { int indexPhoneType = phones.getColumnIndexOrThrow(Phone.TYPE); String phoneType = phones.getString(indexPhoneType); phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); String lookupKey = phones.getString(phones.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); if (colorcounter &lt; 5) { color_string =Color.parseColor(colorcounter_array[colorcounter]); colorcounter++; } else { colorcounter = 0; color_string =Color.parseColor(colorcounter_array[colorcounter]); colorcounter++; } contactWrap.add(new ContactsWrapper(contactId, display_name, phoneNumber,lookupKey,false,color_string)); } // map.put(contactId, new ArrayList&lt;ContactsWrapper&gt;(contactWrap)); phones.close(); } } catch (Exception e) { e.printStackTrace(); } } controller.contactWrapper = contactWrap; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } return null; } @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); constants.dismissDialog(); adapter = new ContactsAdapter(cntx); contactsList.setAdapter(adapter); } } </code></pre> <p>and this is my contact wrapper class</p> <pre><code>public class ContactsWrapper { private long contactId; private String displayName,displayNumber,lookUp; public boolean checked = true; int color_string; public ContactsWrapper(long contactId, String displayName, String displayNumber, String lookUp, boolean checked,int color_string) { // TODO Auto-generated constructor stub this.contactId = contactId; this.displayName = displayName; this.displayNumber = displayNumber; this.lookUp = lookUp; this.checked = checked; this.color_string =color_string; } public String getLookUp() { return lookUp; } public int getColor_string() { return color_string; } public boolean isChecked() { return checked; } public long getContactId() { return contactId; } public String getDisplayName() { return displayName; } public String getDisplayNumber() { return displayNumber; } public void setChecked(boolean checked) { this.checked = checked; } } </code></pre> <p>dont panic dude just match list with thar birthdate and take one temp arraylist and when any name match then add in that temp arraylist and then show that list view according to that temp arraylist :) here i give u code and hint i think it will help u to achieve whatever u want...:)</p> <pre><code>ArrayList&lt;String&gt; matchname = new ArrayList&lt;String&gt;(); for(int l =0;l&lt;contactarraylist.size();l++) { String keyname = contactarraylist[k]; if((keyname.trim().equals("birthdate_string"))) { matchname.add(keyname); } } } </code></pre>
 

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