Distinguish email adresses of a contact

I have 3 email's of the same contact. I need to update this emails to phone book of android. The problem is that when I try do this, the 3 email's are updated the same way. The 3 email's stay equals. Exist any way to distinguish the emails?

Here is my code

if(numEmails>1){
         int auxNumEmails=1;
         String tagEtEmail = "ete";
         String tagBtnLabelEmail = "btnLabelMail";
         //Determinar o nĂșmero de email do content
         do{
             EditText etEmail = (EditText)contentEmail.findViewWithTag(tagEtEmail);
             Button etBtnLabelEmail = (Button)contentEmail.findViewWithTag(tagBtnLabelEmail);
             String stEtEmail = etEmail.getText().toString();
             String stBtnLabelEmail = etBtnLabelEmail.getText().toString();
             values.clear();

             String mailWhere = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?" + ContactsContract.CommonDataKinds.Email.DATA+"=?"; 
             String[] mailWhereParams = new String[]{String.valueOf(idContacto),ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, "2"}; 
             values.put(ContactsContract.CommonDataKinds.Email.DATA,stEtEmail);

             if(stBtnLabelEmail == "ResidĂȘncia"){
             values.put(ContactsContract.CommonDataKinds.Email.TYPE,ContactsContract.CommonDataKinds.Email.TYPE_HOME);
             values.put(ContactsContract.CommonDataKinds.Email.LABEL,stBtnLabelEmail);
             }
             else
                 if(stBtnLabelEmail == "Emprego"){
                     values.put(ContactsContract.CommonDataKinds.Email.TYPE,ContactsContract.CommonDataKinds.Email.TYPE_WORK);
                     values.put(ContactsContract.CommonDataKinds.Email.LABEL,stBtnLabelEmail);
                 }
             **cr.update(ContactsContract.Data.CONTENT_URI, values, mailWhere, mailWhereParams);**

         tagEtEmail = "ete"+auxNumEmails;
         tagBtnLabelEmail = "btnLabelMail" + auxNumEmails;
         auxNumEmails++;

         }while(auxNumEmails<=numEmails);

I need a way to distinguish the emails. Id? But how? Any idea? I appreciate your help. Thanks :)

Answers


The solution that i use to distinguish diferent emails for the same contact is use the tag atribute. Each email have a diferent tag that allow distinguish each one.


Need Your Help

How can I center a TextView on Android?

android android-layout

I have a simple layout that only has one EditText and one TextView:

Keep only second attribute from each line

linux bash sed awk cut

I have a csv file with 4 attributes in each line, delimited by comma. I'm trying to come up with a sed command to keep only the second attribute from each line. Any ideas on how to do it?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.