What is com.android.externalstorage?

寵の児 提交于 2021-02-08 08:05:28

问题


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?


回答1:


How Android Storage works?

To ensure security between Android apps, Android didn't let you directly access every files 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 toward directory of Podcasts in your External Storage.

By having Uri, you can communicate between apps or service provider in an easy way 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 happen 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.



来源:https://stackoverflow.com/questions/51005727/what-is-com-android-externalstorage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!