Q:

How to programatically check the available space on Google Drive from an Android app

I am trying to upload a file from my Android app which I am able to. But before that I want to check the available space on my Google Drive.
I am using Google Drive API (version 2). I tried multiple option but wasn't able to find that information.
Can someone tell me how to fetch the Google Drive free space. 

A:

have a look at this great sample: Documentation
private static void printAbout(Drive service) {
   try {
     About about = service.about().get().execute();

     System.out.println("Current user name: " + about.getName());
     System.out.println("Root folder ID: " + about.getRootFolderId());
     System.out.println("Total quota (bytes): " + about.getQuotaBytesTotal());
     System.out.println("Used quota (bytes): " + about.getQuotaBytesUsed());
         // TOTAL - USED = FREE SPACE
   } catch (IOException e) {
     System.out.println("An error occurred: " + e);
   }

}

