1<?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>
20    <group>Content</group>  <!-- This field will be deprecated in the future
21                            and replaced with the "categories" tags below. -->
22    <package>com.example.android.scopeddirectoryaccess</package>
23
24    <minSdk>24</minSdk>
25
26    <!-- Include additional dependencies here.-->
27    <dependency>com.android.support:recyclerview-v7:28.0.0</dependency>
28
29    <template src="base" />
30
31    <strings>
32        <intro>
33<![CDATA[
34This sample demonstrates how to use the Scoped Directory Access API introduced in Android N
35to easily access to specific directories such as Pictures, Downloads instead of requesting
36READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE in your manifest.
37]]>
38        </intro>
39    </strings>
40
41    <metadata>
42        <status>DEPRECATED</status>
43        <categories>Content</categories>
44        <technologies>Android</technologies>
45        <languages>Java</languages>
46        <solutions>Mobile</solutions>
47        <level>BEGINNER</level>
48        <icon>screenshots/icon-web.png</icon>
49        <screenshots>
50            <img>screenshots/1.png</img>
51            <img>screenshots/2.png</img>
52            <img>screenshots/3.png</img>
53        </screenshots>
54        <api_refs>
55            <android>android.os.storage.StorageManager</android>
56            <android>android.os.storage.StorageVolume</android>
57        </api_refs>
58
59        <description>
60<![CDATA[
61This sample demonstrates how to use the Scoped Directory Access API introduced in Android N
62to easily access to specific directories such as Pictures, Downloads instead of requesting
63READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE in your manifest.
64]]>
65        </description>
66
67        <!-- Multi-paragraph introduction to sample, from an educational point-of-view.
68        Makrdown formatting allowed. This will be used to generate a mini-article for the
69        sample on DAC. -->
70        <intro>
71<![CDATA[
72This sample demonstrates how to use the Scoped Directory Access API that provides easy way to
73access specific directories instead of:
74 - Requesting READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE in your manifest, which allows
75   access to all public directories on external storage.
76 - Using the Storage Access Framework, where the user usually picks directories via a System UI,
77   which is unnecessary if you app always accesses to the same external directory.
78
79To access to a specific directory, use a new Intent created using the StorageVolume class like
80following:
81
82```
83StorageManager sm = getSystemService(StorageManager.class);
84StorageVolume volume = sm.getPrimaryVolume();
85Intent intent = volume.createAccessIntent(Environment.DIRECTORY_PICTURES);
86startActivityForResult(intent, request_code);
87```
88
89Note that the argument passed to StorageVolume.createAccessIntent needs to be one of the
90values of Environment.DIRECTORY_\*.
91
92Once the user grants the access, `onActivityResult` override will be called with a
93result code of `Activity.RESULT_OK` and an intent data that contains the URI representing
94the directory.
95]]>
96        </intro>
97    </metadata>
98</sample>
99