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
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.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: