title: How to get list of documents from a collection in Firestore Android
body: <p>My structure of Firestore database:</p>
  
  <pre><code>|
  |=&gt;root_collection
                    |
                    |=&gt;doc1
                           |                  
                           |=&gt;collection
                    |
                    |=&gt;doc2
                           |                  
                           |=&gt;collection
                    |
                    |=&gt;doc3
                           |                  
                           |=&gt;collection
  </code></pre>
  
  <p>Now I wanna get list of document from <code>root_collection</code>. There would be a list with following data <code>{"doc1", "doc2", "doc3"}</code>. I need it because I want to make a spinner and put these data in the spinner. Then a user would be choose some document and download it.</p>
  
  <p>I try to use the code below:</p>
  
  <pre><code>firestore.collection("root_collection")
              .get()
              .addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
                  @Override
                  public void onComplete(@NonNull Task&lt;QuerySnapshot&gt; task) {
                      if (task.isSuccessful()) {
                          for (QueryDocumentSnapshot document : task.getResult()) {
                              Log.d(TAG,document.getId() + " =&gt; " + document.getData());
                          }
                      } else {
                          Log.d(TAG, "Error getting documents: ", task.getException());
                      }
                  }
              });
  </code></pre>
  
  <p>But the code works only then I have structure of data without collections in the documents. In other case there aren't any documents in <code>QueryDocumentSnapshot</code>.</p>
  
  <p>Thanks!</p>