標籤:
本文將介紹如何去研究android的四大組件之一contentProvider,由於我暫時會用到contacts和calendars,就介紹這2個內容先.
轉載請表明來自於http://my.oschina.net/moziqi/blog
首先我介紹我用的工具先,不如會讓讀者迷惑.
我用的是eclipse+genymotion+sqlite Expert Persional,另外我基於android4.0(14版本來弄的,舊版本我不會介紹,你們可以參考我這個來學低版本),我啟動的模擬器是4.4.4,但我教會用4.0的文檔來說,差異應該不會好大
首先當然要啟動相應的軟體吧,如果沒有相應的軟體,可以自己去下載,尤其genymotion這個軟體,需要註冊才可以使用,
配置上面的東西後,在eclipse啟動genymotion,開啟eclipse視圖File Explorer就會顯示如所示:
展開顯示開啟到data->data->com.android.provider.contacts,暫時介紹這個先
把contacts.db匯出到外面,點中contacts.db按按鈕,就可以匯出,看如何匯出
把contacts.db匯入到sqlite Export Persional中就會顯示出來好多張表,如所示
由於這個些表是android內建的,我們看完到這裡之後,就有必要瞭解下什麼叫contentProvider,另外我們也有必要去瞭解這裡面的表欄位有那些,是為了開發做鋪墊.另外不僅僅是表,還有幾個視圖
在說表的欄位前面,我們來介紹下Contacts Provider(連絡人提供者)
(引用官網的文章)
能翻牆,看英文的童靴就最好自己去看下,不太懂英文,就看寫國內的文章,加深對這些概念的理解吧.
The Contacts Provider is a powerful and flexible Android component that manages the device‘s central repository of data about people.
這Contacts Provider 是一個很強大和靈活的Android組件.操控連絡人
Contacts Provider Organization(結構圖)
主要是有3張表
The three tables are commonly referred to by the names of their contract classes. The classes define constants for content URIs, column names, and column values used by the tables:
ContactsContract.Contacts table
Rows representing different people, based on aggregations of raw contact rows.
ContactsContract.RawContacts table
Rows containing a summary of a person‘s data, specific to a user account and type.
ContactsContract.Data table
Rows containing the details for raw contact, such as email addresses or phone numbers.
The other tables represented by contract classes in ContactsContract are auxiliary tables that the Contacts Provider uses to manage its operations or support specific functions in the device‘s contacts or telephony applications.
raw可以翻譯成源(表示來Google/百度),就是來自那裡的連絡人意思吧.
2015-1-2
開啟源碼路徑,自己去下載,別問我怎麼下載
D:\adt-bundle-windows-x86-20140321\sdk\sources\android-19\android\provider
看下自己想看的源碼類
算了,不想磨磨擦,你們自己剩下自己去自學去吧.
看懂這邊文章http://blog.csdn.net/qingye_love/article/details/9028503
(android)解剖contentProvider-001