Google Drive not showing all files in a directory

I’m new to JSON stuff and could not figure out why I’m having this issue, so here I am. I have a google drive folder that is publicly shared ( Here’s the code I use to get entries (it’s for testing atm):

new Thread(() -> {
        String sUrl = "";

        try {
            URL url = new URL(sUrl);
            URLConnection urlConnection = url.openConnection();

            JsonParser jp = new JsonParser();
            JsonElement root = jp.parse(new InputStreamReader((InputStream) urlConnection.getContent()));
            JsonObject rootObj = root.getAsJsonObject();
            JsonArray files = rootObj.get("files").getAsJsonArray();

            for (JsonElement file : files) {
                String n = file.getAsJsonObject().get("name").getAsString();
                Log.e("amt", counter.getAndIncrement() + "");
                //if (n.toLowerCase().contains(name.toLowerCase())) ret.add(n);

            ((HttpsURLConnection) urlConnection).disconnect();

        } catch (Exception e) {


This code prints the numbers 0-99 in the console, always stopping at 99, despite the folder having more files than that. If anyone has a clue as to why this is happening, please let me know. Alternative methods are welcome as wel!


In your situation, how about using pageSize to the query parameter? The default value of pageSize is 100. I thought that your issue might be due to this default value. So please modify your endpoint as follows and test it again.


String sUrl = "";


String sUrl = "";
  • pageSize=1000 was added to the endpoint.


  • If the number of files is over 1000, you can retrieve all file list using pageToken.