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 last seen in the Bermuda Triangle.

The Storage Access Framework Participants

The preview of this section apparently resembled a Pokémon.

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

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

Opening a Document

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

Why We Want Things To Be Openable

The preview of this section did not survive Thanos's finger snap.

The Rest of the CRUD

The preview of this section apparently resembled a Pokémon.

The DocumentFile Helper

The preview of this section is in an invisible, microscopic font.

CWAC-Document and DocumentFileCompat

The preview of this section is en route to Mars.

Getting Durable Access

The preview of this section is presently indisposed.

Another Durable Example: Diceware

The preview of this section did not survive Thanos's finger snap.

Document Trees

The preview of this section was fed to a gremlin, after midnight.

Getting a Tree: Example

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

Scoped Directory Access Bug

The preview of this section took that left turn at Albuquerque.

Android 8.0 Changes

The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.