I'm trying to update the user profile image in the Firebase Realtime Database on my application but I'm unable to get the reference of the current user as I declare it in another activity.
My code and database structure is as follows:
as in this current picture and the code, I'm writing manually the id of the child node (gli) because it is the user_name of the current user in the firebase, please help me how can I give it a path through coding.
code:
private void profileImage(){
pImageRef = FirebaseDatabase.getInstance().getReference("doctors/doctors_registration/gli/pimage");
pImageRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String imageurl= String.valueOf(dataSnapshot.getValue()) ;
Toast.makeText(HomeActivity.this, "link:"+imageurl, Toast.LENGTH_SHORT).show();
Picasso.get()
.load(imageurl)
.into(profileimg);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Please see the screenshot of the database structure and help me how I can get the current user profile image?