android - Get distinct email id from contact list -


I have a contact list with several names with the same email ID. How can I modify the code given below so that I only name with different e-mail id?

  Public Array List & lt; String & gt; GetNameEmailDetails () {ArrayList & lt; String & gt; Name = new arreelist & lt; String & gt; (); ContentResolver cr = getContentResolver (); Cursor cur = cr.query (ContactsContract.Contacts.CONTENT_URI, faucet, empty, empty, empty); If (cur.getCount () & gt; 0) {while (cur.moveToNext ()) {String id = cur.getString (cur.getColumnIndex (ContactsContract.Contacts._ID)); Cursor cur1 = cr.query (ContactsContract.CommonDataKinds.Email.CONTENT_URI, blank, contactContact.comCommentIndEmailCONTACT_ID + "=?", New string [] {ID}, empty); While (cur1.moveToNext ()) {// Contact name to get the string name = cur1.getString (cur1.getColumnIndex (contactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); Logs. E ("name:", name); String Email = cur1.getString (cur1.getColumnIndex (ContactsContract.CommonDataKinds.Email.DATA)); Logs. ("Email", email); If (email! = Null) {names.add (name); }} Cur1.close (); }} Returning names; }   

To get different values ​​in the esclaim, use the correct only to give a specific value

  cursor cursor = sqliteDB.query (true, "window", new string [] {"mediatip", "_ id", TAG_DATA_OR_LOCATION}, empty, blank, "datarealization" Empty, null, void); Public cursor query (Boolean separation, string table, string [] column, string selection, string [] selectionArgs, string group, string, string command, string border)   

/ Strong> < / P>

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -