title: firebase storage java.lang.IllegalStateException: Task is not yet complete
body: <p>I want to download my all files from the firebase folder on android.</p>
  <blockquote>
  <p>this is my code</p>
  </blockquote>
  <pre><code>try {
          StorageReference reference = storage.getReference().child(&quot;Ringtone&quot;);
      reference.listAll().addOnCompleteListener(new OnCompleteListener&lt;ListResult&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;ListResult&gt; task) {
              if (task.isComplete()){
              task.addOnSuccessListener(new OnSuccessListener&lt;ListResult&gt;() {    /////line 82  == 1st line where i am getting error
                  @Override
                  public void onSuccess(ListResult listResult) {
                      for (StorageReference item : listResult.getItems()) {
  
                          RingtoneModel ringtoneModel = new RingtoneModel();
                          ringtoneModel.setUri(item.getDownloadUrl().getResult());      /////line 88 == 2nd line where i am getting  error here
                          item.getMetadata().addOnSuccessListener(new OnSuccessListener&lt;StorageMetadata&gt;() {
                              @Override
                              public void onSuccess(StorageMetadata storageMetadata) {
                                  ringtoneModel.setSongName(storageMetadata.getName());
                                  Toast.makeText(MainActivity.this, &quot;ring name saved&quot;, Toast.LENGTH_SHORT).show();
                              }
                          }).addOnFailureListener(new OnFailureListener() {
                              @Override
                              public void onFailure(@NonNull Exception e) {
                                  Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                                  Log.e(&quot;metadata error&quot;,e.getMessage());
                              }
                          });
                      }
                  }
              });}else {
                  Toast.makeText(MainActivity.this, (CharSequence) task.getException(), Toast.LENGTH_SHORT).show();
              }
          }
      }).addOnFailureListener(new OnFailureListener() {
          @Override
          public void onFailure(@NonNull Exception e) {
              Log.e(&quot;list all error&quot;,e.getMessage());
          }
      }); }catch (Exception e){
          Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
          Log.e(&quot;all errors&quot;,e.getMessage());}
  }
  </code></pre>
  <blockquote>
  <p>Logcat error message</p>
  </blockquote>
  <pre><code>   /com.example.alarm E/AndroidRuntime: FATAL EXCEPTION: main
          Process: com.example.alarm, PID: 433
          java.lang.IllegalStateException: Task is not yet complete
              at com.google.android.gms.common.internal.Preconditions.checkState(Unknown Source)
              at com.google.android.gms.tasks.zzu.zzb(Unknown Source)
              at com.google.android.gms.tasks.zzu.getResult(Unknown Source)
              at com.example.alarm.MainActivity$3.onSuccess(MainActivity.java:88)
              at com.example.alarm.MainActivity$3.onSuccess(MainActivity.java:82)
  </code></pre>
  <p>my folders and files path in firebase database
  <code>Firebase storage &gt;Rington&lt;my files</code></p>
  <p>&lt;--what i am tried --&gt;
  i tried adding addonsuuccesslistner , addoncompletelitner, task.isComplete(), task.issuccessfull() and may more things</p>