- cú pháp:
<path-permission android:path="string" android:pathPrefix="string" android:pathPattern="string" android:permission="string" android:readPermission="string" android:writePermission="string" />
- có trong:
<provider>
- mô tả:
- Xác định đường dẫn và các quyền cần thiết cho một tập hợp con dữ liệu cụ thể của một nhà cung cấp nội dung. Bạn có thể chỉ định phần tử này nhiều lần để cung cấp nhiều đường dẫn.
- thuộc tính:
android:path
- Một đường dẫn hoàn chỉnh của URI cho một tập hợp con dữ liệu của nhà cung cấp nội dung.
Bạn chỉ có thể cấp quyền cho dữ liệu cụ thể được xác định theo đường dẫn này.
Khi dùng để cung cấp nội dung cụm từ tìm kiếm được đề xuất, thì sẽ có
/search_suggest_query
đi kèm. android:pathPrefix
- Phần tiền tố trong đường dẫn của URI cho một tập hợp con dữ liệu của nhà cung cấp nội dung. Bạn có thể cấp quyền cho tất cả tập hợp con dữ liệu bằng đường dẫn có cùng phần tiền tố này.
android:pathPattern
- Một đường dẫn hoàn chỉnh của URI cho một tập hợp con dữ liệu của nhà cung cấp nội dung, nhưng là loại có thể dùng các ký tự đại diện sau đây:
- Dấu hoa thị (
*
). Ký tự này khớp một chuỗi từ 0 lần xuất hiện đến nhiều lần xuất hiện của ký tự đứng ngay trước đó. - Dấu chấm, theo sau là dấu hoa thị (
.*
). Ký tự này khớp với mọi chuỗi gồm 0 ký tự trở lên.
Vì dấu gạch chéo ngược (
\
) được dùng làm ký tự thoát khi chuỗi được đọc bằng XML, nên bạn sẽ cần dùng 2 ký tự thoát trước khi chuỗi được phân tích cú pháp dưới dạng mẫu. Ví dụ:*
cố định sẽ được viết là "\\*
" và\
cố định sẽ được viết là "\\\
". Nội dung này tương tự như nội dung bạn cần viết khi xây dựng chuỗi trong ngôn ngữ lập trình Java.Để biết thêm thông tin về các loại mẫu này, hãy xem phần mô tả về
PATTERN_LITERAL
,PATTERN_PREFIX
vàPATTERN_SIMPLE_GLOB
trong lớpPatternMatcher
. - Dấu hoa thị (
android:permission
- Tên của một quyền mà ứng dụng cần có để đọc hoặc ghi dữ liệu của nhà cung cấp nội dung. Thuộc tính này là một cách thuận tiện để đặt một quyền duy nhất cho cả chế độ đọc và ghi. Tuy nhiên, các thuộc tính
readPermission
vàwritePermission
được ưu tiên hơn thuộc tính này. android:readPermission
- Một quyền mà ứng dụng cần có để truy vấn nhà cung cấp nội dung.
android:writePermission
- Một quyền mà ứng dụng cần có để thực hiện các thay đổi đối với dữ liệu do nhà cung cấp nội dung kiểm soát.
- ra mắt từ:
- API cấp 4
- xem thêm:
SearchManager
Manifest.permission
- Mẹo bảo mật
<path-permission>
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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)"]]