codecamp

Android 内容提供者URL

内容提供者提供类REST的URL来检索或操纵数据。

Android中的内容URI看起来类似于HTTP URI,除了它们以内容开头并具有一般形式之外。

content://*/*/*

或者

content://authority-name/path-segment1/path-segment2/etc...

例子

NotePadProvider 数据库中标识目录或注释集合的URI是

content://com.google.provider.NotePad/Notes

标识特定注释的URI是

content://com.google.provider.NotePad/Notes/#

其中#是特定注释的ID。

下面是一个示例URI,它标识了注释数据库中的注释编号为9的注释:

content://com.google.provider.NotePad/notes/9

content:之后,URI包含权限的唯一标识符,用于在提供者注册表中定位提供者。

在前面的例子中, com.google.provider.NotePad 是URI的权限部分。

/notes/9 是特定于每个提供者的URI的路径部分。

notes和路径部分的9 部分称为路径段。

每个提供者应该解释URI的路径部分和路径段。

例2

以下代码列出了一些数据提供者接受的URI的示例:

content://media/internal/images
content://media/external/images
content://contacts/people/
content://contacts/people/9

media(content://media)和联系人(content://contacts)没有完全限定的结构。

内容提供者的URI也类似于数据库中的存储过程的名称。

提供者也需要使用任何状态修改方法来改变在此URI中的内容,如:insert,update或delete。



Android 内容提供者
Android 内容提供者MIME类型
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }