Content Provider: in depth

from the CommonsWare Community archives

At November 6, 2021, 2:53pm, ten asked:

Hello,
I would like to know what are the best use cases for Content Provider and what are not .

Is there any alternative for content provider now.


At November 6, 2021, 3:14pm, mmurphy replied:

If you need to share streams or two-dimensional data sets (rows and columns) across processes, ContentProvider is a fine solution.

ContentProvider will not get stains out of your clothes, nor will it bake a cake.

An alternative for doing what?


At November 6, 2021, 3:20pm, ten replied:

In Gmail, When click on Attach file option-> it shows files present in the file system to select and selected file gets loaded . I want to know how this scenario implemented using Content Provider or anything else


At November 6, 2021, 3:34pm, mmurphy replied:

I am uncertain what “this scenario” means.

If you mean that you want to do what Gmail is doing, Gmail probably is using ACTION_OPEN_DOCUMENT, or perhaps ACTION_GET_CONTENT. You will find ACTION_OPEN_DOCUMENT (in the form of ActivityResultContracts.OpenDocument) covered in Elements of Android Jetpack.