- תחביר:
<grant-uri-permission android:path="string" android:pathPattern="string" android:pathPrefix="string" />
- בתוך:
<provider>
- תיאור:
- קביעת קבוצות המשנה של נתוני האפליקציה שספק התוכן הראשי
יש הרשאת גישה. קבוצות משנה של נתונים מסומנות על ידי החלק בנתיב של
URI של
content:
. חלק הרשות ב-URI מזהה את ספק תוכן. הענקת הרשאה היא דרך לאפשר ללקוחות של הספק שלא בדרך כלל מקבלים הרשאה לגשת לנתונים כדי להתגבר על ההגבלה הזו באופן חד-פעמי.אם
grantUriPermissions
של ספק תוכן הואtrue
, ניתן להעניק הרשאה לכל אחד מהנתונים שתחת תפקידו של הספק. עם זאת, אם הערך של המאפיין הואfalse
, ההרשאה מוענק רק לקבוצות משנה של נתונים שמצוינות על ידי הרכיב הזה. ספק יכול להכיל כל מספר של רכיבי<grant-uri-permission>
. כל סוג יכול לציין נתיב אחד בלבד, באמצעות אחד משלושת המאפיינים האפשריים.למידע נוסף על הענקת הרשאה, אפשר לעיין ב של רכיב
<intent-filter>
grantUriPermissions
. - :
android:path
android:pathPrefix
android:pathPattern
- נתיב המזהה את קבוצות המשנה או קבוצות המשנה של הנתונים שאפשר להגדיר את ההרשאה
שניתנה עבורה. המאפיין
path
מציין נתיב מלא. ניתן להעניק הרשאה רק לקבוצת המשנה הספציפית של הנתונים שזוהתה בנתיב הזה.המאפיין
pathPrefix
מציין את החלק הראשוני של הנתיב. אפשר לתת הרשאה לכל קבוצות המשנה של הנתונים שיש להן נתיבים שחולקים של החלק הראשוני. המאפייןpathPattern
מציין נתיב מלא, אבל יכול להכיל את התווים הכלליים לחיפוש הבאים:- כוכבית (
*
) מתאימה רצף של אפס למופעים רבים של את התו הקודם. נקודה ואחריה כוכבית (
.*
) תואמת לכל רצף של בין אפס להרבה תווים.
כי
\
משמש כתו בריחה כשהמחרוזת נקראת מ-XML, לפני שהוא מנתח כדפוס, עליכם לסמן בתו בריחה (escape) פעמיים. לדוגמה,*
בליטרל נכתב כך:\\*
, וגם הליטרל\
נכתב כך:\\\
.למידע נוסף על סוגי הדפוסים האלה, אפשר לקרוא את התיאורים של
PATTERN_LITERAL
,PATTERN_PREFIX
, וגםPATTERN_SIMPLE_GLOB
ב כיתה אחת (PatternMatcher
). - כוכבית (
- הושקו ב:
- רמת API 1
- למידע נוסף:
-
grantUriPermissions
של התכונה<provider>
רכיב
<grant-uri-permission>
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-27 (שעון UTC)."],[],[],null,["# <grant-uri-permission\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cgrant-uri-permission android:path=\"string\"\n android:pathPattern=\"string\"\n android:pathPrefix=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cprovider\u003e](/guide/topics/manifest/provider-element)\n\ndescription:\n: Specifies the subsets of app data that the parent content provider\n has permission to access. Data subsets are indicated by the path part of a\n `content:` URI. The authority part of the URI identifies the\n content provider.\n Granting permission is a way of enabling clients of the provider that don't\n normally have permission to access its data to overcome that restriction on\n a one-time basis.\n\n\n If a content provider's [grantUriPermissions](/guide/topics/manifest/provider-element#gprmsn)\n attribute is `true`, permission can be granted for any of the data under\n the provider's purview. However, if that attribute is `false`, permission\n is granted only to data subsets that are specified by this element.\n A provider can contain any number of `\u003cgrant-uri-permission\u003e` elements.\n Each one can specify only one path, using one of the three possible attributes.\n\n\n For information about how permission is granted, see the\n [\u003cintent-filter\u003e](/guide/topics/manifest/intent-filter-element) element's\n [grantUriPermissions](/guide/topics/manifest/provider-element#gprmsn) attribute.\n\nattributes:\n:\n\n `android:path`\n\n `android:pathPrefix`\n\n `android:pathPattern`\n : A path identifying the data subset or subsets that permission can be\n granted for. The `path` attribute specifies a complete path.\n Permission can granted only to the particular data subset identified\n by that path.\n\n \u003cbr /\u003e\n\n\n The `pathPrefix` attribute specifies the initial part of a path.\n Permission can be granted to all data subsets with paths that share that\n initial part.\n The `pathPattern` attribute specifies a complete path, but one\n that can contain the following wildcards:\n\n - An asterisk (`*`) matches a sequence of zero to many occurrences of the immediately preceding character.\n - A period followed by an asterisk (`.*`) matches any sequence of\n zero to many characters.\n\n\n Because `\\` is used as an escape character when the string is read\n from XML, before it is parsed as a pattern, you need to double-escape.\n For example, a literal `*` is written as `\\\\*` and a\n literal `\\` is written as `\\\\\\`.\n\n\n For more information about these types of patterns, see the descriptions of\n [PATTERN_LITERAL](/reference/android/os/PatternMatcher#PATTERN_LITERAL),\n [PATTERN_PREFIX](/reference/android/os/PatternMatcher#PATTERN_PREFIX), and\n [PATTERN_SIMPLE_GLOB](/reference/android/os/PatternMatcher#PATTERN_SIMPLE_GLOB) in the\n [PatternMatcher](/reference/android/os/PatternMatcher) class.\n\nintroduced in:\n: API level 1\n\nsee also:\n:\n [grantUriPermissions](/guide/topics/manifest/provider-element#gprmsn)\n attribute of the\n [\u003cprovider\u003e](/guide/topics/manifest/provider-element)\n element"]]