- ไวยากรณ์:
<path-permission android:path="string" android:pathPrefix="string" android:pathPattern="string" android:permission="string" android:readPermission="string" android:writePermission="string" />
- ที่อยู่ใน:
<provider>
- description:
- กำหนดเส้นทางและสิทธิ์ที่จำเป็นสำหรับชุดย่อยของข้อมูลที่เฉพาะเจาะจง ภายในผู้ให้บริการเนื้อหา องค์ประกอบนี้สามารถเป็น ระบุไว้หลายครั้งเพื่อระบุหลายเส้นทาง
- ดังนี้
android:path
- เส้นทาง URI ที่สมบูรณ์สำหรับส่วนย่อยของข้อมูลผู้ให้บริการเนื้อหา
ระบบจะให้สิทธิ์ได้เฉพาะข้อมูลที่ระบุโดยเส้นทางนี้เท่านั้น
เมื่อมีการใช้เพื่อแสดงเนื้อหาการแนะนำการค้นหา จะมีการใช้คำนั้นต่อท้าย
ด้วย
/search_suggest_query
android:pathPrefix
- ส่วนเริ่มต้นของเส้นทาง URI สำหรับส่วนย่อยของข้อมูลผู้ให้บริการเนื้อหา คุณให้สิทธิ์ได้กับชุดข้อมูลย่อยทั้งหมดที่มีเส้นทางที่แชร์ส่วนเริ่มต้นนี้
android:pathPattern
- เส้นทาง URI ที่สมบูรณ์ของส่วนย่อยของข้อมูลผู้ให้บริการเนื้อหา
แต่สามารถใช้ไวลด์การ์ดต่อไปนี้
- เครื่องหมายดอกจัน (
*
) จะจับคู่ลำดับ 0 ถึงหลายครั้ง อักขระที่อยู่ก่อนหน้าทันที - จุดตามด้วยเครื่องหมายดอกจัน (
.*
) ซึ่งจะตรงกับลำดับ อักขระตั้งแต่ศูนย์ตัวขึ้นไป
เนื่องจากเครื่องหมายแบ็กสแลช (
\
) ใช้เป็นอักขระหลีกเมื่อมีการอ่านสตริง จาก XML ก่อนที่จะแยกวิเคราะห์เป็นรูปแบบ คุณจะต้อง Escape 2 ครั้ง เช่น*
ตามตัวอักษรก็จะเขียนว่า "\\*
" และ\
แบบตัวอักษรเขียนว่า "\\\
" นี่คือ เหมือนกับที่คุณเขียน หากสร้างสตริงในภาษาโปรแกรม Javaสำหรับข้อมูลเพิ่มเติมเกี่ยวกับรูปแบบประเภทนี้ โปรดดูคำอธิบายของ
PATTERN_LITERAL
PATTERN_PREFIX
และPATTERN_SIMPLE_GLOB
ในPatternMatcher
- เครื่องหมายดอกจัน (
android:permission
- ชื่อสิทธิ์ที่ลูกค้าต้องใช้เพื่ออ่านหรือเขียน
ข้อมูลของผู้ให้บริการเนื้อหา แอตทริบิวต์นี้เป็นวิธีที่สะดวกในการตั้งค่า
สิทธิ์เดียวสำหรับทั้งการอ่านและการเขียน อย่างไรก็ตาม
readPermission
และ แอตทริบิวต์writePermission
มีลำดับความสำคัญเหนือกว่า มากกว่าอันนี้ android:readPermission
- สิทธิ์ที่ลูกค้าต้องใช้เพื่อค้นหาผู้ให้บริการเนื้อหา
android:writePermission
- สิทธิ์ที่ลูกค้าต้องใช้เพื่อทำการเปลี่ยนแปลงข้อมูลที่ผู้ให้บริการเนื้อหาควบคุม
- เปิดตัวใน
- API ระดับ 4
- ดูเพิ่มเติม
SearchManager
Manifest.permission
- เคล็ดลับความปลอดภัย
<path-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,["# <path-permission\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cpath-permission android:path=\"string\"\n android:pathPrefix=\"string\"\n android:pathPattern=\"string\"\n android:permission=\"string\"\n android:readPermission=\"string\"\n android:writePermission=\"string\" /\u003e\n ```\n\ncontained in:\n: [\u003cprovider\u003e](/guide/topics/manifest/provider-element)\n\ndescription:\n: Defines the path and required permissions for a specific subset of data\n within a content provider. This element can be\n specified multiple times to supply multiple paths.\n\nattributes:\n:\n\n `android:path`\n : A complete URI path for a subset of content provider data.\n Permission can be granted only to the particular data identified by this path.\n When used to provide search suggestion content, it is appended\n with `/search_suggest_query`.\n\n `android:pathPrefix`\n : The initial part of a URI path for a subset of content provider data.\n Permission can be granted to all data subsets with paths that share this initial part.\n\n `android:pathPattern`\n : A complete URI path for a subset of content provider data,\n but one that can use the following wildcards:\n\n - An asterisk (`*`). This matches a sequence of zero to many occurrences of the immediately preceding character.\n - A period followed by an asterisk (`.*`). This matches any sequence of zero or more characters.\n\n\n Because the backslash (`\\`) 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 \"`\\\\\\`\". This is\n the same as what you write if constructing the string in the Java programming language.\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\n `android:permission`\n : The name of a permission that clients need in order to read or write the\n content provider's data. This attribute is a convenient way of setting a\n single permission for both reading and writing. However, the\n `readPermission` and\n `writePermission` attributes take precedence\n over this one.\n\n `android:readPermission`\n : A permission that clients need in order to query the content provider.\n\n `android:writePermission`\n : A permission that clients need in order to make changes to the data controlled by the content provider.\n\nintroduced in:\n: API level 4\n\nsee also:\n: [SearchManager](/reference/android/app/SearchManager)\n: [Manifest.permission](/reference/android/Manifest.permission)\n: [Security tips](/guide/topics/security/security)"]]