谷歌驱动器GET_CONTENT意图读取的文件驱动器、意图、文件、GET_CONTENT

2023-09-05 06:02:44 作者:月亮是我踹彎的

我在Android的应用程序,并使用云存储器像Dropbox的一些文件共享。要开始分享我把 android.intent.action.SEND 。 在所显示的列表中我看到了谷歌驱动器应用程序(previously安装),所以我尝试将文件发送到它 - 它的工作原理确定,该文件显示在驱动器列表

然后,另一台设备上我想读这个文件。我扔了 android.intent.action.GET_CONTENT 的意图,选择驱动器,然后不知道怎么去申请。我收到一个开放的我们是这样的:

content://com.google.android.apps.docs.files/exposed_content/6jn9cnzdJbDywpza%2BlW3aA%3D%3D%0A%3BRV%2FaV94o%2FCcW4HGBYArtwOdHqt%2BrsYO4WmHcs6QWSVwp%2FXogkRAgit7prTnfp00a%0A

我不知道如何转化为物理文件路径。我怎么能从此得到的文件内容是什么?

我打得周围的内容提供商,并能获取文件名,而不是完整的路径或其他任何东西。

有关保管箱我得到的文件:// 风格的URI,直接,简单,效果很好。

解决方案

这是送你的URI内容提供商,你可以使用它与ContentResolver的,例如如:

  getContentResolver()查询(URI contentUri,字符串[]投影,选择字符串,字符串[] selectionArgs两个,字符串排序顺序)。
 
文件信息查看器 GetFileInfo 1.0.1绿色版下载

编辑:为了得到真实路径名使用提供以下

解决方案

Android:获取文件的Uri从内容乌里?

I have an app on android that does some file sharing using cloud storages like dropbox. To start sharing I throw android.intent.action.SEND. On the list that is shown I see the Google Drive app (previously installed), so I try sending the file to it - it works ok, the file appears in the Drive list.

Then, on another device I want to read this file. I throw the android.intent.action.GET_CONTENT intent, choose Drive and then don't know how to get to file. I receive an Uri something like this:

content://com.google.android.apps.docs.files/exposed_content/6jn9cnzdJbDywpza%2BlW3aA%3D%3D%0A%3BRV%2FaV94o%2FCcW4HGBYArtwOdHqt%2BrsYO4WmHcs6QWSVwp%2FXogkRAgit7prTnfp00a%0A

which I don't know how to transform to physical file path. How could I get the file contents from this?

I played around the content provider and can get the file name, but not the full path or anything else.

For the dropbox I get the file:// style uri, straight and simple, works well.

解决方案

It is sending you uri of content provider which you can use it with ContentResolver,for example such as:

getContentResolver().query(Uri contentUri, String[] projection, String selection, String[] selectionArgs, String sortOrder);

Edit: For getting real path names use the solution provided below

Android: Getting a file Uri from a content Uri?

 
精彩推荐
图片推荐