Google Drive Web Services API for Android - Displaying File Names In A Folder -



Google Drive Web Services API for Android - Displaying File Names In A Folder -

i'm using google drive web services api android app i'm making. right now, i'm trying obtain list of filenames in root folder. however, believe current method doing inefficient:

public void searchroot() { thread t = new thread(new runnable() { @override public void run() { seek { children.list request = service.children().list("root"); { seek { childlist children = request.execute(); for(childreference kid : children.getitems()) { file file = service.files().get(child.getid()).execute(); } request.setpagetoken(children.getnextpagetoken()); } catch(ioexception e) { request.setpagetoken(null); } } while(request.getpagetoken() != null && request.getpagetoken().length() > 0); } catch(ioexception e) { } } }); t.start(); }

i think method inefficient because first phone call request.execute() list of children in root folder, have phone call service.files().get(child.getid()).execute() on each , every child, in order obtain human-readable filename each child. if there's big number of files in root folder, can take arbitrarily big amount of time filenames. question -- there improve way obtaining list of filenames? query can homecoming of filenames in root folder 1 api call?

as aside, understand google drive sdk has functionality i'm requesting. however, take utilize google drive web services api because i'm trying stream non-public media google drive account, , don't believe drive sdk has back upwards that.

i figured out. instead of using service.children().list("root"), utilize service.files().list().setq("'root' in parents")

public void searchroot() { thread t = new thread(new runnable() { @override public void run() { seek { com.google.api.services.drive.drive.files.list request = service.files().list().setq("'root' in parents"); { seek { filelist children = request.execute(); for(file kid : children.getitems()) { log.d("debug", child.gettitle()); } request.setpagetoken(children.getnextpagetoken()); } catch(ioexception e) { request.setpagetoken(null); } } while(request.getpagetoken() != null && request.getpagetoken().length() > 0); } catch(userrecoverableauthioexception e) { startactivityforresult(e.getintent(), request_search_root); } catch(ioexception e) { } } }); t.start(); }

android google-drive-sdk

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -