Home > Net >  How to Update Firebase Realtime Database a Specific Child Node/
How to Update Firebase Realtime Database a Specific Child Node/

Time:06-08

This is my Firebase node real-time database structure:

I wanr to update userProfilePic in this structure.

I try my best but this is not being updated

here is my code

database.getReference()
    .child("User")
    .child(FirebaseAuth.getInstance().uid.toString())
    .child("userProfilePic")
    .setValue(uri)
    .addOnSuccessListener { 

    }
    .addOnFailureListener {
        Toast.makeText(this,it.message,Toast.LENGTH_SHORT).show()
    }

please tell me how I can update in kotlin in android studio

CodePudding user response:

I think you should reconsider this snippet code

child(FirebaseAuth.getInstance().toString())

CodePudding user response:

You should refer to currentUser when calling for uid like this:

FirebaseAuth.getInstance().currentUser.uid

Instead of:

FirebaseAuth.getInstance().uid.toString()
  • Related