Advertisements

FS DB Delete with callback

        //Getting instance
        FirebaseFirestore db = FirebaseFirestore.getInstance();


        //Getting Reference to "users" collection
        final DocumentReference docRef = db.collection("users").document("new doc");


        //Deleting document named "new doc"
        docRef.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if(task.isSuccessful()){
                    //File Deleted
                }else{
                    //Something went wrong, logging the error message
                    Log.e(TAG, "onComplete: Error: " + task.getException().getLocalizedMessage() );       
                }
            }
        });