The simplest solution to delete a record from a Firebase Realtime Database is to use "removeValue()" method as shown in the following lines of code:
val rootRef = FirebaseDatabase.getInstance().getReference()
val friendIdRef = rootRef.child("requests/${firebaseUser.uid}/requests/${friendId}")
friendIdRef.removeValue().addOnCompleteListener(object : OnCompleteListener<Void?>() {
fun onComplete(task: Task<Void?>) {
if (task.isSuccessful()) {
Log.d(TAG, "Item successfully deleted.")
}
}
})
The delete() method that you are using is apart of the Firestore SDK. While both databases are apart of Firebase, both are two different products, with two different mechanisms.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…