use of com.google.api.services.drive.Drive.Files in project keepass2android by PhilippC.
the class GoogleDriveFileStorage method listFiles.
@Override
public List<FileEntry> listFiles(String parentPath) throws Exception {
GDrivePath gdrivePath = new GDrivePath(parentPath);
String parentId = gdrivePath.getGDriveId();
List<FileEntry> result = new ArrayList<FileEntry>();
Drive driveService = getDriveService(gdrivePath.getAccount());
try {
if (driveService.files().get(parentId).execute().getLabels().getTrashed())
throw new FileNotFoundException(parentPath + " is trashed!");
logDebug("listing files in " + parentId);
Files.List request = driveService.files().list().setQ("trashed=false and '" + parentId + "' in parents");
do {
try {
FileList files = request.execute();
for (File file : files.getItems()) {
String path = new GDrivePath(parentPath, file).getFullPath();
logDebug("listing file " + path);
FileEntry e = convertToFileEntry(file, path);
result.add(e);
}
request.setPageToken(files.getNextPageToken());
} catch (IOException e) {
System.out.println("An error occurred: " + e);
request.setPageToken(null);
throw e;
}
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
} catch (Exception e) {
throw convertException(e);
}
return result;
}
use of com.google.api.services.drive.Drive.Files in project Aegis by Decad3nce.
the class BackupGoogleAccountsActivity method getAegisFolder.
private static String getAegisFolder() {
Files.List request = null;
String folderID = null;
try {
request = service.files().list().setQ("mimeType= 'application/vnd.google-apps.folder' and title = 'aeGis Backup' and trashed = false");
} catch (IOException e) {
e.printStackTrace();
return null;
}
do {
FileList files;
try {
files = request.execute();
for (File file : files.getItems()) {
folderID = file.getId();
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
// Log.i(TAG, "FolderID: " + folderID);
return folderID;
}
Aggregations