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