content provider主要用于在不同的應(yīng)用程序之間實(shí)現(xiàn)數(shù)據(jù)共享的功能拒垃。
使用content provider是android實(shí)現(xiàn)實(shí)現(xiàn)跨程序共享數(shù)據(jù)的標(biāo)準(zhǔn)方式窍侧。
權(quán)限分為普通權(quán)限和危險(xiǎn)權(quán)限(需要運(yùn)行時(shí)授權(quán))县踢。
查詢是否有權(quán)限??要求權(quán)限??獲得權(quán)限后繼續(xù)操作
使用contentResolver進(jìn)行數(shù)據(jù)操作,通過(guò)content URI獲取信息伟件。
content URI由authority和path組成硼啤。
authority用于區(qū)別應(yīng)用
path用于區(qū)別數(shù)據(jù)表
如content://com.example.app.provider/table1
自定義content provider的話需要復(fù)寫相關(guān)方法,在其中進(jìn)行數(shù)據(jù)庫(kù)操作
可以使用uriMatcher區(qū)分解析content uri的內(nèi)容
盡量使用NotificatinoCompat類
點(diǎn)擊完就消失可以用setAutoCancel方法
有不同的style斧账,如bigText谴返,bigPicture
android7.0之后,直接使用本地真實(shí)路徑的Uri被認(rèn)為是不安全的咧织,會(huì)拋出一個(gè)fileUriExposedException異常嗓袱。(不可以直接Uri.fromFile獲取)