java - Getting an id for existing dir on Drive -
i trying id existing dir on google drive.
com.google.api.services.drive.model.about = drive.about().get().execute(); com.google.api.services.drive.drive.children.list list = drive.children().list(about.getrootfolderid()); iterator<entry<string, object>> itr = list.entryset().iterator(); entry<string, object> s; while (itr.hasnext()) { s = itr.next(); system.out.println(s.getkey() + "::" + s.getvalue()); }
right code giving output -
folderid::0apcebfk-cf2puk9pva
which not correct id because have 2 dirs , 3 files in google drive. must missing something, right way id of existing dir.
i have seen this question, , helpful if can equivalent java example. using same account's google drive owning app.
create list of files , iterate.
drive service = new drive.builder(httptransport, jsonfactory, credential1).build(); string query = "'" + about.getrootfolderid() +"' " + "in parents"; list<file> files = service.files().list().setq(query).execute().getitems(); return files;
this should do.
Comments
Post a Comment