0

I am trying to delete user document from the firebase firestore , but neither deleting nor giving error, Although task.isSuccessfull is working deleted toast is showing but data is not deleted in firestore.

Below is my database and code.

void clearAll() {

    FirebaseFirestore db = FirebaseFirestore.getInstance();



 db.collection("messeges").document(firebaseuser.getUid).delete().addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if(task.isSuccessful()){
                Toast.makeText(MainActivity.this, "Deleted", Toast.LENGTH_SHORT).show();
            }
            else{
                Toast.makeText(MainActivity.this, "Not Deleted", Toast.LENGTH_SHORT).show();
            }
        }
    });
}

enter image description here

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

1

Your screenshot shows a collection called "messages" with three documents that don't actually exist. You can tell they don't exist because they are in italics. However, the console still shows them because they have nested subcollections ("shivang") that still exist - the display of the missing document is required so that you can still see and navigate into that data.

Deleting a document does not delete any nested subcollections. You have to delete each nested document individually.

Read the documentation about this.

See also:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441