Home > OS >  Android Documents Provider how to use and do I need it?
Android Documents Provider how to use and do I need it?

Time:07-05

I'm going to create an app for accessing the files from the Internet. I do not want to implement UI, but instead to make them visible from other file managers. So, I chose to implement a Document Provider. And I did it. On the next pictures you can see that I open "Files" app, find "My document provider" and can access its files.

enter image description here enter image description here enter image description here

However, it's an emulator. When I tried to use the app on my physical device I found that I have no ways to see document providers. I use Xiaomi Redmi Note 5 Pro (android 9.0) there is no "Files" app. I tested top ~20 File Managers from Google Play and even MIUI build in file-explorer, but none of them can show me my "My document provider".

I managed to see my documents provider only when tried to attach a document from Gmail app. But it's not what I need.

Questions:

  1. am I right that Documents Provider is not what I need?
  2. Am I right it's rather an ADDITIONAL way to share the files with other client apps which use Storage Access Framework (like Gmail, photo editor, etc), but was not designed to be used as the main method for accessing the files?
  3. Am I right that I have to implement my own Activities with UI and full functionality of file explorer as a main approach for user to access his files? (like Google Drive app - it has both: own UI for managing the files and documents provider accessible from system picker)

CodePudding user response:

I do not want to implement UI, but instead to make them visible from other file managers

You have no means of forcing other apps to do much of anything. In particular, you have no means of forcing a file manager to show things from your app.

Am I right it's rather an ADDITIONAL way to share the files with other client apps which use Storage Access Framework (like Gmail, photo editor, etc), but was not designed to be used as the main method for accessing the files?

Correct. A DocumentsProvider is for making documents available via the Storage Access Framework. A file manager could elect to show documents from the registered DocumentsProvider implementations on the device. In practice, I am not surprised that few file managers do this. You might consider contributing that feature to open source file managers.

Am I right that I have to implement my own Activities with UI and full functionality of file explorer as a main approach for user to access his files?

That is up to you. If you want your app to be guaranteed to do something for all of your users, having your own UI for traversing your collection of documents would be a good idea.

  • Related