0

Anyone knows how I can update two emails in phone book of android with same TYPE

(for example: TYPE_HOME), but update each mail with a different string.

In my way I update the emails, but the emails that have the same TYPE, are updated simultaneously with the same string and i don't want this.

What I want

Email_1->TYPE_HOME->String_Hello

Email_2->TYPE_HOME->String_Hello_again

Different string but the same type.

Here is my code

         EditText etEmail = (EditText)contentEmail.findViewWithTag("ete1");
         String stEtEmail = etEmail.getText().toString();   
         values.clear();
         Log.w(SocioEdit.class.getName(), "TESTE DO TYPE" +String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE).charAt(3));
         String mailWhere = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=? AND " + String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE) + "= ?"; 
         String[] mailWhereParams = new String[]{String.valueOf(idContacto),ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE,String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_HOME)}; 
         values.put(ContactsContract.CommonDataKinds.Email.DATA,stEtEmail);
         Log.w(SocioEdit.class.getName(),"TESTE DA STRING DO EMAIL-->" +stEtEmail); 
         cr.update(ContactsContract.Data.CONTENT_URI,values, mailWhere, mailWhereParams);
     }
Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
Ricardo Filipe
  • 435
  • 4
  • 8
  • 24

1 Answers1

0

As we know that Email has a stored in Data table, So it has its id and we can get the data ID as well as Email type and Email information

so if we get the email Id in data table

we can do it like this:

cr.update(ContactsContract.Data.CONTENT_URI,values, Data.id+"=?", new String[]{String.valueOf(ID)});