android - App showing contact numbers three times -
i have created app in when button clicked activity opens , user has select contact. numbers contact has displayed on screen. working fine contact having more 3 numbers. when contact selected has 1 number , app instead of showing number 1 time shows same numbers 3 times.
here code
string contactnumber = ""; if(integer.parseint(cursor.getstring(cursor.getcolumnindex(contactscontract.contacts.has_phone_number))) > 0 ){ cursor phonecursor = getcontentresolver().query(contactscontract.commondatakinds.phone.content_uri,null, contactscontract.commondatakinds.phone.contact_id + " = " + indexid, null,null); while(phonecursor.movetonext()){ if(phonecursor.getcount() > 1){ contactnumber = contactnumber + "," + phonecursor.getstring(phonecursor.getcolumnindex(contactscontract.commondatakinds.phone.number)); contact_num = (textview) findviewbyid(r.id.contact_number); contact_num.settext(contactnumber); } else { contactnumber = phonecursor.getstring(phonecursor.getcolumnindex(contactscontract.commondatakinds.phone.number)); contact_num = (textview) findviewbyid(r.id.contact_number); contact_num.settext(contactnumber); break; } } } }
Comments
Post a Comment