0

Here I am trying to access the imgURL. Below I am trying to upload an image from my local storage onto the firebase storage. After doing so I would like to store that link into imgURL but I instead I am just getting null from imgURL.

private String imgURL;
StorageReference filepath1 = mStorage.child("Blog_Image").child(mcontentURI.getLastPathSegment() + random());

filepath1.putFile(mcontentURI).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
    @Override
    public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
      final Uri downlaodUrl = taskSnapshot.getDownloadUrl();
      imgURL = downlaodUrl.toString();
    }
 });
  • Add this line before final Uri downloadUrl.... System.out.println("====== URL ===="+taskSnapshot.getDownloadUrl()); and verify in Android monitor Whether you get the url or not. – Andy Developer Sep 14 '17 at 12:50
  • See https://stackoverflow.com/questions/5977735/setting-outer-variable-from-anonymous-inner-class – Frank van Puffelen Sep 14 '17 at 13:34

0 Answers0