"Original" Reprint please Cabernet blog address http://www.cnblogs.com/scarecrow-blog/p/6266042.html
Personal feeling this is a bug in Android provider, nonsense less say directly on the code
1 Publicstring getcanonicaladdresses (String recipient_ids) {2String[] Ids=recipient_ids.split ("");3System.out.println ("Recipient_ids:" +recipient_ids);4String addressresult= "";5 for(inti = 0; i < ids.length; i++) {6Cursor cur=readsmsactivity. This. Getcontentresolver (). Query (Uri.parse ("content://mms/"), 7 Newstring[]{"* from canonical_addresses where _id=" +ids[i].tostring () + "--"},NULL,NULL,NULL);8 if(Cur.getcount () >0){9 while(Cur.movetonext ()) {TenString _id=cur.getstring (Cur.getcolumnindex ("_id")); OneString address=cur.getstring (Cur.getcolumnindex ("Address")); Aaddressresult+= "{" +_id+ "," +address+ "}"; - } - } the } - returnAddressresult; -}
Looking at lines 6th and 7th, MMS provider actually queries MMS-related content and does not provide canonical-address query functionality. However, the above writing, through the query method into the parameters of the projection directly write almost the entire query statement, and after the "-" to realize the direct query of the DB through MMS provider canonical_addresses table function.
Principle:
As we all know, projection is usually the name of each column in the table to be looked up, so the SQL statement that was finally spelled out to execute in the database is similar to the SELECT projection from table where ....
But here the projection is completely replaced with another complete statement, so the final spell looks roughly like the select * from canonical_addresses where _id= "2"-the From table where ....
The "--" in Sql is the meaning of the comment. This method is the use of this point, the original provider through the URI-qualified query statement into another query statement, thus obtaining a private table query results.
Android uses provider to query tables that are not exposed in the same database