title: Google Drive Get Files From Folder
body: <p>How to get list of file of specific folder from google drive using drive api</p>
  
  <p>Ref :: <a href="https://developers.google.com/drive/android/deprecation" rel="nofollow noreferrer">https://developers.google.com/drive/android/deprecation</a></p>
  
  <h3><code>FileList</code></h3>
  
  <pre><code> public  Task&lt;FileList&gt; fetchLatestInformation(@NotNull String backupDir) {
          return Tasks.call(mExecutor, () -&gt; {
              Drive.Files.List list = drive.files().list().setFields("nextPageToken, files(id, name, modifiedTime, size, createdTime, parents, appProperties)");
              StringBuilder sb = new StringBuilder();
              sb.append("mimeType = 'application/vnd.google-apps.folder' and name = '");
              sb.append(backupDir);
              sb.append("'");
              list.setQ(sb.toString());
              list.setPageSize(1000);
              list.setOrderBy("modifiedTime");
              return list.execute();
          });
      }
  </code></pre>
  
  <h3><code>ActivityCode</code></h3>
  
  <pre><code>    googleDrive.fetchLatestInformation(backupDir)
              .addOnSuccessListener {
                  var files = it.files
                  files.reverse()
                  files.forEach {
                      Log.e(TAG,"file :: ${it?.name}")
                  }
                  var file = files.firstOrNull()
  
                  if (file != null) {
                      var time = file.modifiedTime
                      var date = Date(time.value)
                      var simpleDateFormat = SimpleDateFormat("EEE, dd MMM yyyy hh:mm aaa")
                      Log.e(TAG,"lastBackup name :: ${file.name}")
                      Log.e(TAG,"lastBackup date :: ${simpleDateFormat.format(date)}")
                      Log.e(TAG,"lastBackup size :: ${file.getSize()?.formatFileSize}")
  
                  }
              }
              .addOnFailureListener {
                  it.printStackTrace()
              }
  </code></pre>
  
  <h3><code>LogResult</code></h3>
  
  <pre><code>E/BackupActivity: file :: AppBackup
  E/BackupActivity: lastBackup name :: AppBackup
  E/BackupActivity: lastBackup date :: Tue, 19 May 2020 10:44 PM
      lastBackup size :: null
  </code></pre>
  
  <p>but <code>AppBackup</code> is directory which contains the backup files zips so my question is how to get a files which is stored in <code>AppBackup</code> Directory.</p>
  
  <p>NOTE :: <a href="https://developers.google.com/drive/api/v3/" rel="nofollow noreferrer">I AM USING DRIVE API V3</a></p>