Android N Feature Spotlight: Navigation Buttons Now Dim For A Slightly-Tweaked Lights Out Mode
Video: Apps Install (Much) Faster On Android N
Android N Feature Spotlight: Scoped Directory Access Gives Apps An Easy Way To Ask Users For Access To Common Folders
Android N Feature Spotlight: Apps In The Share Menu Can Be Pinned To The Top Of The List
Android N Feature Spotlight: Multiple Device Locales Are Now Supported, Allowing Search Results In Multiple Languages And Other Goodies
- View All 91 Articles In This Series
File storage on Android has been a complicated subject over the years. It started very simply with private folders for each app and a pair of permissions for read and write access to just about everything else. The seeds of change were planted with Honeycomb when Google quietly closed off write access to secondary storage like SD cards, but most people didn't take notice until Google insisted OEMs enforce the same rules in KitKat.
Each year since, new APIs have been introduced to give developers new ways to work with the filesystem or even abstract it out of view while also improving security and maintaining privacy. Android N continues this forward momentum with a new API called Scoped Directory Access that gives control over access back to users with Marshmallow-style permission requests.
The Scoped Directory Access API is basically a simple way for an app to request access to one of the system-defined media and content folders like Pictures and Downloads. When the request is made, the operating system will check to see if the app already has access to that folder, and if not, it will prompt the user with a dialog that looks just like the permission requests introduced with Marshmallow.
The directories an app can currently request access to include: Music, Podcasts, Ringtones, Alarms, Notifications, Pictures, Movies, Downloads, DCIM, and Documents.
Sample permission request dialog.
Once permission is granted to a folder, an app can continue to read and write to it without repeatedly prompting the user. Access to a folder also grants access to all of the files and folders beneath it, and the same functionality is available with removable media like SD cards and USB drives, as well. Scoped Directory Access is tailored to be the best solution for apps like photo viewers, music players, and text editors.
One of the small advantages that also comes with the Scoped Directory Access API is that it doesn't require any of the old permissions, so developers can leave out READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE – assuming the app doesn't have to support anything before Android N. Okay, so that's a perk that won't truly apply for a couple of years, but developers can still set a maxSdkVersion parameter on permissions that are not required above a certain API level.
If you're looking to implement Scoped Directory Access in your app, check out the developer page with more details and best practices.
In Android N, apps can use new APIs to request access to specific external storage directories, including directories on removable media such as SD cards. The new APIs greatly simplify how your application accesses standard external storage directories, such as the
Picturesdirectory. Apps like photo apps can use these APIs instead of using
READ_EXTERNAL_STORAGE, which grants access to all storage directories, or the Storage Access Framework, which makes the user navigate to the directory.
Additionally, the new APIs simplify the steps a user takes to grant external storage access to your app. When you use the new APIs, the system uses a simple permissions UI that clearly details what directory the application is requesting access to.
For more information, see the Scoped Directory Access developer documentation.
Quoted from: N Preview Overview