2

Hello: i would like how to remove or delete a folder with it's content in FirebaseStorage?

i do have an admin app for admin to edit and delete items, i can delete items from FirebaseDatabase but can't delete FirebaseStorage.

Code to remove FirebaseRealTime:

productRef.addListenerForSingleValueEvent(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot snapshot) {
        //If UID Existed Then would start Deleting
        if (snapshot.child(et_UID.getText().toString()).exists()) {
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which){
                        case DialogInterface.BUTTON_POSITIVE:
                            //Remove Image Folder / Product
                            productRef.child(et_UID.getText().toString()).removeValue();
                            productImagesRef.child(et_UID.getText().toString()).delete();
                            break;

                        case DialogInterface.BUTTON_NEGATIVE:
                            //No button clicked
                            break;
                    }
                }
            };
            AlertDialog.Builder builder = new AlertDialog.Builder(UpdateActivity.this);
            builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
                    .setNegativeButton("No", dialogClickListener).show();
        } else {
            Toast.makeText(UpdateActivity.this, "UID Doesn't Exist.", Toast.LENGTH_SHORT).show();
        }
    }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
MiniDev99
  • 324
  • 1
  • 13
  • https://stackoverflow.com/questions/38214052/delete-folder-with-contents-from-firebase-storage? – Frank van Puffelen Oct 27 '21 at 20:46
  • this answer is for ios and swift, i am using android – MiniDev99 Oct 27 '21 at 22:57
  • There is zero code in that answer, and it applies equally to any client-side SDK. ¯\_(ツ)_/¯ If you've tried the approach suggested there and are having a hard time making it work for you in Android, I recommend editing your question to show what you tried. Otherwise anything we answer is either going to repeat that answer (I just updated it for some changes since then), or do the writing of the code for you - which I don't think is what you're after. – Frank van Puffelen Oct 27 '21 at 23:52
  • What have you tried in code that doesn't work to remove the items? – Alex Mamo Oct 28 '21 at 06:58
  • productImagesRef.child(et_UID.getText().toString()).delete(); – MiniDev99 Oct 28 '21 at 08:02

0 Answers0