blob: d008782b329ba23e80def91627bed2eab6f05610 [file] [log] [blame]
Takeshi Hagikura5d1466d2016-03-01 18:20:15 +09001<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2016 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17
18<sample>
19 <name>ScopedDirectoryAccess</name>
Trevor Johnsdea54462016-03-08 15:50:43 -080020 <group>Android N Preview</group> <!-- This field will be deprecated in the future
Takeshi Hagikura5d1466d2016-03-01 18:20:15 +090021 and replaced with the "categories" tags below. -->
22 <package>com.example.android.scopeddirectoryaccess</package>
23
Trevor Johnsf9872de2016-06-15 09:52:40 -070024 <minSdk>24</minSdk>
25 <compileSdkVersion>24</compileSdkVersion>
26 <targetSdkVersion>24</targetSdkVersion>
Takeshi Hagikura5d1466d2016-03-01 18:20:15 +090027
28 <!-- Include additional dependencies here.-->
Trevor Johnsad6207d2016-06-14 15:42:02 -070029 <dependency>com.android.support:appcompat-v7:24.0.0-beta1</dependency>
30 <dependency>com.android.support:recyclerview-v7:24.0.0-beta1</dependency>
31 <dependency>com.android.support:support-v4:24.0.0-beta1</dependency>
Takeshi Hagikura5d1466d2016-03-01 18:20:15 +090032
33 <template src="base" />
34
35 <strings>
36 <intro>
37<![CDATA[
38This sample demonstrates how to use the Scoped Directory Access API introduced in Android N
39to easily access to specific directories such as Pictures, Downloads instead of requesting
40READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE in your manifest.
41]]>
42 </intro>
43 </strings>
44
45 <metadata>
Trevor Johnsdea54462016-03-08 15:50:43 -080046 <status>PUBLISHED</status>
Takeshi Hagikura5d1466d2016-03-01 18:20:15 +090047 <categories>Android N Preview</categories>
48 <technologies>Android</technologies>
49 <languages>Java</languages>
50 <solutions>Mobile</solutions>
51 <level>BEGINNER</level>
52 <icon>screenshots/icon-web.png</icon>
53 <screenshots>
54 <img>screenshots/1.png</img>
55 <img>screenshots/2.png</img>
56 <img>screenshots/3.png</img>
57 </screenshots>
58 <api_refs>
59 <android>android.os.storage.StorageManager</android>
60 <android>android.os.storage.StorageVolume</android>
61 </api_refs>
62
63 <description>
64<![CDATA[
65This sample demonstrates how to use the Scoped Directory Access API introduced in Android N
66to easily access to specific directories such as Pictures, Downloads instead of requesting
67READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE in your manifest.
68]]>
69 </description>
70
71 <!-- Multi-paragraph introduction to sample, from an educational point-of-view.
72 Makrdown formatting allowed. This will be used to generate a mini-article for the
73 sample on DAC. -->
74 <intro>
75<![CDATA[
76This sample demonstrates how to use the Scoped Directory Access API that provides easy way to
77access specific directories instead of:
78 - Requesting READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE in your manifest, which allows
79 access to all public directories on external storage.
80 - Using the Storage Access Framework, where the user usually picks directories via a System UI,
81 which is unnecessary if you app always accesses to the same external directory.
82
83To access to a specific directory, use a new Intent created using the StorageVolume class like
84following:
85
86```
87StorageManager sm = getSystemService(StorageManager.class);
88StorageVolume volume = sm.getPrimaryVolume();
89Intent intent = volume.createAccessIntent(Environment.DIRECTORY_PICTURES);
90startActivityForResult(intent, request_code);
91```
92
93Note that the argument passed to StorageVolume.createAccessIntent needs to be one of the
94values of Environment.DIRECTORY_\*.
95
96Once the user grants the access, `onActivityResult` override will be called with a
97result code of `Activity.RESULT_OK` and an intent data that contains the URI representing
98the directory.
99]]>
100 </intro>
101 </metadata>
102</sample>