All About Content

Files and databases are for storage that your app manages. When you need to
share information with other apps — or with the OS itself —
we tend to turn towards content. Android’s
content system allows us to interact with other apps as if they offered tiny
REST-style Web services, without the overhead and security issues involved
in TCP/IP.

During this one-day seminar, we will explore the following:

Inside the Uri

What is a Uri?

What are the pieces of a Uri?

What are common Uri schemes in Android?

Where do we get a Uri from?

Consuming Content Streams

What is the Storage Access Framework?

What are the Android equivalents of the “open file” and “save as” dialogs that you see on other platforms?

We get a Uri back from that — how do we use this?

How can we get metadata about the content, such as its size or some sort of “name”?

How long can we use that Uri, and what do we do if we need access to that content for a longer time?

Consuming Database-Style Content

What are common database-style ContentProviders in Android?

How do we get permission to work with those providers?

How can we query them for data?

What is the Loader framework, and what is it loading?

How can we manipulate (insert/update/delete) database-style content?

ContentProvider Basics

What exactly is a ContentProvider, anyway?

How do we add one to our app?

What are the key methods that a ContentProvider will implement?

Using FileProvider and StreamProvider

What is FileProvider, and what problems does it solve?

How do I theoretically add FileProvider to my app?

What problems does FileProvider have?

What is StreamProvider, and what does it do differently from FileProvider?

How do I add StreamProvider to my app?

Implementing a Streaming Provider

How do I stream content from an ordinary file?

How do I stream content that I need to modify (e.g., decode) or generate?

What problems will I run into when clients try using my streams?

What does Android 8.0’s ProxyFileDescriptorCallback do for me?

Implementing a Database-Style Provider

How do I implement the query(), insert(), update(), and delete() methods?