How to get the file ID so I can perform a download of a file from Google Drive API on Android?

后端 未结 7 1079
[愿得一人]
[愿得一人] 2020-12-29 04:37

I am working on an Android project and I am trying to make use of the Google Drive API and I\'ve got most of it working but I am having an issue in how I perform a download.

相关标签:
7条回答
  • 2020-12-29 05:19

    Stan0 intial idea is not a good idea. There can be multiple files with the same name. Very error prone implementation. Stan0's second idea is the correct way.

    When you first upload the file to google drive store its id (in SharedPreferences is probably easiest) for later use

    ie.

    file= mDrive.files().insert(body).execute();      //initial insert of file to google drive
    
    whereverYouWantToStoreIt= file.getId(); //now you have the guaranteed unique id 
                                            //of the file just inserted. Store it and use it 
                                            //whenever you need to fetch this file
    
    0 讨论(0)
提交回复
热议问题