修改如下:
1. 添加URI
修改ContactsProvider2.java,
private static final int PHONE_LOOKUP = 4000;
下面加入一行:
private static final int PHONE_LOOKUP2 = 4001; // New Add
matcher.addURI(ContactsContract.AUTHORITY, "provider_status", PROVIDER_STATUS);
下面加入一行:
matcher.addURI(ContactsContract.AUTHORITY, "phone_lookup2", PHONE_LOOKUP2); // New Add
2. 实现处理对应URI的方法
修改contactsProvider2.java 的 updateInTransaction().
case PHONE_LOOKUP2:
final SQLiteDatabase mDb = mDbHelper.get().getWritableDatabase(); // mDb
Cursor c = mDb.query(Tables.PHONE_LOOKUP,
new String[]{ PhoneLookupColumns.DATA_ID,
PhoneLookupColumns.RAW_CONTACT_ID,
PhoneLookupColumns.NORMALIZED_NUMBER,
PhoneLookupColumns.MIN_MATCH },
null, null, null, null, null);
while(c.moveToNext()) {
long dataId = c.getLong(0);
long rawContactId = c.getLong(1);
String normalizeNumber = c.getString(2);
String oldMinMatch = c.getString(3);