update contact query

update query to remove duplicated numbers

Fixes #4191
Closes #6475
This commit is contained in:
AndHell 2017-04-11 18:48:22 +02:00 committed by Moxie Marlinspike
parent 12ce92bb83
commit dc18f73594

View File

@ -161,9 +161,11 @@ public class ContactsDatabase {
put(LABEL_COLUMN, ContactsContract.CommonDataKinds.Phone.LABEL); put(LABEL_COLUMN, ContactsContract.CommonDataKinds.Phone.LABEL);
}}; }};
String excludeSelection = ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " NOT IN (" + String formattedNumber = "REPLACE(REPLACE(REPLACE(REPLACE(data1,' ',''),'-',''),'(',''),')','')";
"SELECT data.contact_id FROM raw_contacts, view_data data WHERE raw_contacts._id = data.raw_contact_id AND " + String excludeSelection = "(" + formattedNumber +" NOT IN " +
"data.mimetype = '" + CONTACT_MIMETYPE + "')"; "(SELECT data1 FROM view_data WHERE "+formattedNumber+" = data1) " +
"OR "+formattedNumber+" = data1)" +
"AND " + formattedNumber + "NOT IN (SELECT "+formattedNumber+" FROM view_data where mimetype = '"+CONTACT_MIMETYPE+"')" ;
String fallbackSelection = ContactsContract.Data.SYNC2 + " IS NULL OR " + ContactsContract.Data.SYNC2 + " != '" + SYNC + "'"; String fallbackSelection = ContactsContract.Data.SYNC2 + " IS NULL OR " + ContactsContract.Data.SYNC2 + " != '" + SYNC + "'";