skip to Main Content

I’m building a program that needs the ability to delete an image and video at the same time for when updating a new image and new video, but doing it with 1 delete process.

StorageReference mPicRef = FirebaseStorage.getInstance().getReferenceFromUrl(editImage);

StorageReference mVidRef = FirebaseStorage.getInstance().getReferenceFromUrl(editVideo);

mPicRef.delete(), mVidRef.delete().addOnSuccessListener(// rest of code here

I’m not sure on how to handle this delete process.

2

Answers


  1. If you want to delete two objects in Storage using the Firebase SDK, then you will have to call delete() once on each object reference. There is no way to make two deletes happen at the same time, and there is no way to delete using a wildcard.

    Login or Signup to reply.
  2. As Doug answered, there’s no Firebase API call to delete multiple storage references at the same time. But in your Android code, you can use Tasks.whenAll to have a single completion listener for all of the operations:

    Tasks.whenAll(Arrays.asList(mPicRef, mVidRef)).addOnSuccessListener(...);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search