title: Matching incoming and outgoing phone numbers
body: <p>I'm currently making an SMS viewing application and using the ContentResolver to obtain all SMS messages on the phone (Yes, I understand the risks). Like other applications, I want to group all messages from the same person to one thread, display the latest message from them, and order the contacts by date of the last message.</p>
  
  <p>When it comes to the address values of the incoming messages, they all contain the country code (e.g. +44123456789). But when the user saves his contacts, he could ignore the country code and simply type in the local format. So all outgoing messages are stored as 0123456789.</p>
  
  <p>So, the database will contain the same address in both formats, +44123456789 and 0123456789. How do you match this 2 and remove the duplicate address?</p>
  
  <p>Note:
  1) Messages from the same person may not have the same "thread id"
  2) There may not be a "contact id"/"display name" value for the address </p>