grant-uri-permission-element.jd revision 3001a035439d8134a7d70d796376d1dfbff3cdcd
1page.title=<grant-uri-permission>
2@jd:body
3
4<dl class="xml">
5<dt>syntax:</dt>
6<dd><pre class="stx">&lt;grant-uri-permission android:<a href="#path">path</a>="<i>string</i>"
7                      android:<a href="#path">pathPattern</a>="<i>string</i>"
8                      android:<a href="#path">pathPrefix</a>="<i>string</i>" /&gt;</pre></dd>
9
10<dt>contained in:</dt>
11<dd><code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code></dd>
12
13<dt>description:</dt>
14<dd>Specifies which data subsets of the parent content provider permission
15can be granted for.  Data subsets are indicated by the path part of a 
16{@code content:} URI.  (The authority part of the URI identifies the
17content provider.)  
18Granting permission is a way of enabling clients of the provider that don't 
19normally have permission to access its data to overcome that restriction on 
20a one-time basis.
21
22<p> 
23If a content provider's <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmns">grantUriPermissions</a></code> 
24attribute is "{@code true}", permission can be granted for any the data under 
25the provider's purview.  However, if that attribute is "{@code false}", permission 
26can be granted only to data subsets that are specified by this element.  
27A provider can contain any number of {@code &lt;grant-uri-permission&gt;} elements.  
28Each one can specify only one path (only one of the three possible attributes).
29</p>
30
31<p>
32For information on how permission is granted, see the 
33<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code> element's
34<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn">grantUriPermissions</a></code> attribute.
35</p></dd>
36
37<dt>attributes:</dt>
38<dd><dl class="attr">
39<dt><a name="path"></a>{@code android:path}
40<br/>{@code android:pathPrefix}
41<br/>{@code android:pathPattern}</dt>
42<dd>A path identifying the data subset or subsets that permission can be 
43granted for.  The {@code path} attribute specifies a complete path; 
44permission can be granted only to the particular data subset identified 
45by that path.  
46The {@code pathPrefix} attribute specifies the initial part of a path; 
47permission can be granted to all data subsets with paths that share that 
48initial part.   
49The {@code pathPattern} attribute specifies a complete path, but one 
50that can contain the following wildcards:
51
52<ul>
53<li>An asterisk ('{@code *}') matches a sequence of 0 to many occurrences of
54the immediately preceding character.</li>
55
56<li><p>A period followed by an asterisk ("{@code .*}") matches any sequence of 
570 to many characters.</p></li>
58</ul>
59
60<p>
61Because '{@code \}' is used as an escape character when the string is read 
62from XML (before it is parsed as a pattern), you will need to double-escape:  
63For example, a literal '{@code *}' would be written as "{@code \\*}" and a 
64literal '{@code \}' would be written as "{@code \\\\}".  This is basically 
65the same as what you would need to write if constructing the string in Java code.
66</p>
67
68<p>
69For more information on these types of patterns, see the descriptions of 
70{@link android.os.PatternMatcher#PATTERN_LITERAL},
71{@link android.os.PatternMatcher#PATTERN_PREFIX}, and
72{@link android.os.PatternMatcher#PATTERN_SIMPLE_GLOB} in the
73{@link android.os.PatternMatcher} class.
74</p></dd>
75</dl></dd>
76
77<dt>see also:</dt>
78<dd>the 
79<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmns">grantUriPermissions</a></code>
80attribute of the 
81<code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code> 
82element</dd>
83
84
85</dl>
86