如何从Firebase数据库删除图像?

时间:2019-05-07 16:46:27

标签: android firebase firebase-realtime-database

我要从Firebase存储中删除图像。

这是我的Firebase数据库。

enter image description here

1 个答案:

答案 0 :(得分:0)

您需要使用以下方法调用:

StorageReference photoRef = mFirebaseStorage.getReferenceFromUrl(mImageUrl);

然后按原样删除:

photoRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
    // File deleted successfully
    Log.d(TAG, "onSuccess: deleted file");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
    // Uh-oh, an error occurred!
    Log.d(TAG, "onFailure: did not delete file");
}});