How to get file name and real path of Google drive document?

前端 未结 2 630
天命终不由人
天命终不由人 2020-12-18 23:23

I am using the following code to get the file name and path of files in the File Manager. However it does not return a path for Google Drive files. Any idea how to obtain th

2条回答
  •  无人及你
    2020-12-18 23:47

    You have to use the URI. Through the URI you can getContentResolver.query(theUriThatYouHave, null, null, null, null). Now that you have a cursor, you can check column names etc.

    For Google drive there is a column name _display_name. This will give you the file name.

    Now you want access to the file? You can open an InputStream to the URI via getContentResolver().openInputStream(theUriThatYouHave).

提交回复
热议问题