How to Download mp3 file from google drive in android

与世无争的帅哥 提交于 2020-01-06 19:31:32

问题


I am working on Android application in which i have to download audio files from google drive and then save these files in sd-card.. Is there any api or sample project that helps me in downloading mp3 files from google drive

OR Is there any other way to to download mp3 file from google drive programatically...

Can we use public downloadable url for achieving above mentioned purpose

Thanks


回答1:


There are two a APIs that that allow you to do it. The GDAA and the REST. None of them deals with the mp3 files specifically, though. The APIs deal with a binary file content only. That means you:

  1. Find the file first. Either you know the name, mime type,... or you know it's Id. If you use REST, the Id can be extracted from the file's URL.
  2. Download the content as a binary stream.
  3. Save the content as an mp3 file on Android.

If you insist on applying the URL based Id, it is easier to use the REST, since:

  • the URL directly corresponds with the REST Id (aka ResourceId in GDAA)
  • you can use the REST playground (bottom) to test things interactively

Also, you may use the demo code here to see the (dis)advantages of using one API or another. It deals with jpg content instead of mp3, but it has all the building blocks you need. Be sure you understand the relation of DriveId and ResourceId.

Good Luck




回答2:


Go to Developers Google Website click here

you will get information how to download file.



来源:https://stackoverflow.com/questions/29343041/how-to-download-mp3-file-from-google-drive-in-android

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