小编Ali*_*omy的帖子

如何从 firebase 获取另一个用户数据?

我希望当用户单击管理员个人资料时,用户可以看到管理员信息。我使用 currentUser 来获取已在应用程序中登录的当前用户的 id。

我想知道如何获取另一个用户数据。

    String currentuser = FirebaseAuth.getInstance().getCurrentUser().getUid();


    // init firebase database
    mUserDatabaseReference = FirebaseDatabase.getInstance().getReference("Users");

    mUserDatabaseReference.child(currentuser).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {


            // here using Picasso for get the image url and set in ImageView
            String imageUrl = dataSnapshot.child("profile_pic").getValue().toString();
            Picasso.with(AboutCompany_for_users.this).load(imageUrl).into(companyPhoto);


            String name = dataSnapshot.child("name").getValue().toString();
            String email = dataSnapshot.child("email").getValue().toString();
            String phone = dataSnapshot.child("mobile").getValue().toString();
            String busesNumbers = dataSnapshot.child("buses_numbers").getValue().toString();
            String lineName = dataSnapshot.child("bus_line").getValue().toString();


            // here we get the data from
            companyName.setText(name);
            companyEmail.setText(email);
            companyPhone.setText(phone);
            companyBusesNumbers.setText(busesNumbers);
            companyLineName.setText(lineName);

        }

        @Override
        public void …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-authentication

5
推荐指数
2
解决办法
4746
查看次数