anonymous
anonymous

Reputation: 41

Can Google Drive Android API be used to list all the files on google drive?

I want to list all the file on user's google drive(all files not just created by application) and then download the selected one. I found there are two APIs Google Drive API for android and Google Drive REST API. After searching a lot i know that i can get list of files using REST API but not sure about Android API. Please guide me how to proceed.

Upvotes: 1

Views: 349

Answers (1)

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17651

Files.list can be used for Android as well. You can see that in this Android Quickstart

/**
 * Fetch a list of up to 10 file names and IDs.
 * @return List of Strings describing files, or an empty list if no files
 *         found.
 * @throws IOException
 */
private List<String> getDataFromApi() throws IOException {
    // Get a list of up to 10 files.
    List<String> fileInfo = new ArrayList<String>();
    FileList result = mService.files().list()
         .setPageSize(10)
         .setFields("nextPageToken, files(id, name)")
         .execute();
    List<File> files = result.getFiles();
    if (files != null) {
        for (File file : files) {
            fileInfo.add(String.format("%s (%s)\n",
                    file.getName(), file.getId()));
        }
    }
    return fileInfo;
}

Upvotes: 1

Related Questions