Pro Android with Kotlin


CHAPTER 6: Content Providers


Download 5.42 Mb.
Pdf ko'rish
bet67/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   63   64   65   66   67   68   69   70   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

70
CHAPTER 6: Content Providers

grant-uri-permission:
android:pathPattern="string"
android:pathPrefix="string" />
This grants a specific URI permission (use zero to many instances of that child). Only if the 
parent’s attribute grantUriPermissions is set to false will this child allow the access to 
specific URIs. Use exactly one of these attributes: path is for the complete URI, pathPrefix 
is for URIs starting with that value, and pathPattern allows for wildcards (X* is for zero to 
many repetitions of any character X, and .* is for zero to many repetitions of any character).

path-permission:
android:pathPrefix="string"
android:pathPattern="string"
android:permission="string"
android:readPermission="string"
android:writePermission="string" />
To define a subset of data a content provider can serve, you can use this element to 
specify a path and a required permission. The path attribute specifies a complete path, 
the pathPrefix attribute allows matching the initial part of a path, and pathPattern is a 
complete path, but with wildcards (* matches zero to many occurrences of the preceding 
character, and .* matches zero to many occurrences of any character). The permission 
attribute specifies both a read and a write permission, and the attributes readPermission and 
writePermission draw a distinction between read and write permission. If one of the latter 
two is specified, it takes precedence over the permission attribute.
Designing Content URIs
URIs describe the domain of the data a content requester is interested in. Thinking of SQL, 
this would be the table name. URIs can do more, however. The official syntax of a URI is as 
follows:
scheme:[//[user[:password]@]host[:port]]
[/path][?query][#fragment]
You can see that the user, password, and port parts are optional, and in fact you usually 
wouldn’t specify them in an Android environment. They are not forbidden, though, and 
make sense under certain circumstances. The host part, however, is interpreted in the 
most general way as something that provides something, and this is exactly the way it is 
interpreted here, with “something” being the data. To make that notion somewhat clearer
the host part for Android is commonly referred to as the authority. For example, in the 
Contacts system app, the authority would be com.android.contacts. (Don’t use strings; use 
class constant fields instead. See the “Contract” section for more information.) The scheme is 
by convention normally content. So, a general contacts URI starts with the following:
content://com.android.contacts



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   63   64   65   66   67   68   69   70   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling