Android MMS: A summary of conversations and contact relationships _android

Source: Internet
Author: User

In MMS, eachThreadhas a corresponding contact, butThreadsThe table does not directly save the contact's information (number or name), but instead saves a message calledrecipient_id, there is also a class calledData/recipientidcache.javaspecialize in managing it.

There is a special table in the database to save itcanonical_addresses。 Its purpose is to be able to quickly find information about a contact person in a conversation. Table of DialogsThreadsThere is no direct information to save the contact person, but a column calledRecipient_idsInteger to represent the addressee. And there's another table in the database calledcanonical_addresses, which is used to matchThreadsIn theRecipient_idsAnd number, which has only two columns, one is _id, and the other is its number. Because the conversation does not directly save the contact information, so whenconversationlistWant to display aThread, you need to find it first.RecipientidAnd then according to this recipientid tocanonical_addressesFind the number in the, and then use this number to contact the database to query other information about the contact person. This whole process is quite cumbersome, need to query three times database to get contact information, can not be quickly displayed. So there it is.RecipientidcacheThis class has a hash table inside this class, and the key isThreadOfRecipientid, the value is the number of the contact person. Other classes, such asConversationIn the queryThreadWill not go directly to the querycanonical_addressesTable to get the correspondingRecipientidThe number of the contact person, but directly through theRecipientidcacheTo get.RecipientidcacheFirst of all from their ownCacheTo find the number, if not found to query the database, and add toCacheIn Every time you send a message, you will update the cache action. BecauseRecipientidIsThreadA property in theThreadWhen a table is changed, such as deleting aThreadwill be updated when youRecipientidcache

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.