
Contacts Provider是官方寫好的提供聯絡人的資訊
這篇就介紹基本的用法
1. 官網https://developer.android.com/guide/topics/providers/contacts-provider.html
RX1226 發表在 痞客邦 留言(0) 人氣(1,014)

當你想提供下列功能時就需要適合使用Content Provider:
a. 將資料或檔案提供給其他App。
b. 讓使用者從你的App複製資料到其他App。
c. 使用搜尋架構提供自訂搜尋建議。
d. 想要將資料給widgets使用
e. 想要使用 AbstractThreadedSyncAdapter, CursorAdapter, 或CursorLoader
RX1226 發表在 痞客邦 留言(0) 人氣(1,417)

ContentUris是專門用來處理scheme為content的Uri
可以用來解析字尾的id, 或是新增id上去
這邊先解釋一下在Content provider內Uri的基本組成
<scheme>://<authority>/<path>/<id>
RX1226 發表在 痞客邦 留言(0) 人氣(220)

UriMatcher是content providers用來比對Uri所使用的
用法很簡單, 就是先給予訓練劇本之後
輸入對應的Uri就會回對應的值
void addURI(String authority, String path, int code)
用來指定Uri以及該回傳的值
int match(Uri uri)
用來判斷Uri, 並傳回對應的值
RX1226 發表在 痞客邦 留言(0) 人氣(609)

Content Provider的使用時機有兩種
一種是當你想要使用別人提供的資料
另一種是你想要提供資料讓別人使用
在使用的範圍有
a. 分享你的app資料給其他的app
b. 將資料送到widget
c. 使用SearchRecentSuggestionsProvider自訂搜尋建議
d. 使用AbstractThreadedSyncAdapter將資料同步到server
e. 使用CursorLoader把資料呈現在UI上面
RX1226 發表在 痞客邦 留言(0) 人氣(251)