Search code examples
androidxamarinxamarin.androidandroid-file

What is com.android.externalstorage?


Despite this being a simple question I cannot find the answer on google or stackoverflow.

When I use the following code I get this result //com.android.externalstorage.documents/tree/primary:Podcasts

var intent = new Intent(Intent.ActionOpenDocumentTree);
intent.PutExtra("android.content.extra.SHOW_ADVANCED", true);
intent.PutExtra("android.content.extra.FANCY", true);
intent.PutExtra("android.content.extra.SHOW_FILESIZE", true);

Can you help me understand the parts of my result?


Solution

  • How Android Storage works?

    To ensure security between Android apps, Android didn't let you directly access every file within the storage system. They have something called ContentProvider.

    Think of this content provider like a waiter, that your apps can ask for a certain file/folder (through Content Uri).

    Content Uri will look like this: content://[Authority]/[path]/[id] is just an example of Content Uri. com.android.externalstorage.documents is an example of authority (for access to External Storage providers).

    So in your case, your Uri will gain you access to the directory of Podcasts in your External Storage.

    By having Uri, you can communicate between apps or service provider easily without having to pass real file every time you ask or give one. Just pass a lightweight simple Uri.

    What happened in your code?

    If you're wondering what happens in your code, try to look at the Reference.

    It says:

    Allow the user to pick a directory subtree. When invoked, the system will display the various DocumentsProvider instances installed on the device, letting the user navigate through them. Apps can fully manage documents within the returned directory.

    I'm not sure what you're trying to achieve (please clarify if you can, so I can help out), but I hope my answer contains enough information.