Go directlyCode...
View code
1 Cursor ccursor = getcontentresolver (). Query (contacts. content_uri, Null , Null , Null , Null );
2 Cursor dcursor;
3 Startmanagingcursor (ccursor );
4 While (Ccursor. movetonext ()){
5 // Get the name directly
6 System. Out. println ("name:" + ccursor. getstring (ccursor. getcolumnindex (contacts. display_name )));
7 // Query the data table based on the ID of the contacts table
8 Dcursor = getcontentresolver (). Query (data. content_uri, Null , Data. raw_contact_id + "=? ", New String [] {ccursor. getstring (ccursor. getcolumnindex (contacts. _ id ))}, Null );
9 Startmanagingcursor (dcursor );
10 While (Dcursor. movetonext ()){
11 // Determine whether the mimetype of this row in the data table is phone
12 If (Dcursor. getstring (dcursor. getcolumnindex (data. mimetype). Equals (phone. content_item_type )){ // Yes
13 // Value of the data2 field in the switchdata table
14 Switch (Dcursor. getint (dcursor. getcolumnindex (data. data2 ))){
15 // Phone. type_mobile indicates the mobile phone number.
16 Case Phone. type_mobile:
17 System. Out. println ("mobile phone number:" + dcursor. getstring (dcursor. getcolumnindex (data. data1 )));
18 Break ;
19 // Phone. type_home is a landline phone.
20 Case Phone. type_home:
21 System. Out. println ("landline:" + dcursor. getstring (dcursor. getcolumnindex (data. data1 )));
22 Break ;
23 }
24 }
25 }
26 }
The tables used in the contacts database
This table stores some contact IDs or something.
This table stores information about the corresponding IDs in the corresponding contacts table. the data category corresponds to mimetype_id. data1, data2, and so on. Different mimetype have different functions. For example, if mimetype is phone, data1 stores the phone number and data2 stores the category, for example, the mobile phone number, fixed phone number, company number, and so on. You will know what else you need.
We can use mimetype to determine what data is stored.
I use Firefox's SQLite manager to browse databases. I just need to export the corresponding database and use SQLite manager to open it. There are a lot of databases under data/data. You can find what you want.