简体   繁体   中英

How to Delete value from Firebase realtime database by key in android?

I have realtime database in firebase it look like this

在此处输入图片说明

Now I want to delete value by key in android (java).

I have tried this code

DatabaseReference ref = FirebaseDatabase.getInstance().getReference();

ref.child("coating").child("88").removeValue().addOnSuccessListener(new OnSuccessListener<Void>() {
    @Override
    public void onSuccess(Void aVoid) {

        Toast.makeText(activity, "on success", Toast.LENGTH_SHORT).show();

    }
}).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {

        Toast.makeText(activity, "on success"+e.getMessage(), Toast.LENGTH_SHORT).show();
    }
});


I get success response in onSuccess Method but value in database is not deleted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM