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
During this one-day seminar, we will explore the following:
Inside the Uri
- What is a
- What are the pieces of a
- What are common
Uri schemes in Android?
- Where do we get a
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?
- What exactly is a
- 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
- What is
StreamProvider, and what does it do differently from
- 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
- Do I bother implementing
bulkInsert(), and if so, how do I do that?
- This seems very tedious — can’t we make this simpler somehow?
Implementing a DocumentsProvider
- What is a
- Why would I want to implement one?
- How do I create a basic
- What additional Storage Access Framework features can I opt into?