The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Consuming Documents

Android has long offered the ability for an app to pick some file or stream from another app and consume it. However, the original options were designed around an app loading content from another app. Even though our code would be requesting content based on abstractions like MIME types, the implementation and user experience would be based on the traditional “pick an app to fulfill this request” chooser.

Google, given its clear interest in cross-cutting storage engines like Google Drive, wanted something better. In Android 4.4, they added the Storage Access Framework (SAF) to provide a better user experience, with only modest changes to client code. With Android’s increasing reliance upon content and document providers for cross-app content sharing, understanding the Storage Access Framework is fairly important for modern app development.

In this chapter, we will examine what it takes to consume documents published via the SAF.

Prerequisites

This chapter assumes that you have read the chapter on ContentProvider patterns or have equivalent experience with consuming streams published by a ContentProvider.

The Storage Access… What?

The preview of this section was traded for a bag of magic beans.

The Storage Access Framework Participants

The preview of this section was traded for a bag of magic beans.

Picking How to Pick (a Peck of Pickled Pepper Photos)

The preview of this section is presently indisposed.

Opening a Document

The preview of this section is being chased by zombies.

Why We Want Things To Be Openable

The preview of this section was stepped on by Godzilla.

The Rest of the CRUD

The preview of this section was lost in the sofa cushions.

The DocumentFile Helper

The preview of this section was traded for a bag of magic beans.

CWAC-Document and DocumentFileCompat

The preview of this section was traded for a bag of magic beans.

Getting Durable Access

The preview of this section was whisked away by a shark-infested tornado.

Another Durable Example: Diceware

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Document Trees

The preview of this section was traded for a bag of magic beans.

Getting a Tree: Example

The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.

Scoped Directory Access Bug

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Android 8.0 Changes

The preview of this section was abducted by space aliens.