This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

How to display username and email from firebase in android  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import androidx.annotation.NonNull;

import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.s.attendancemanagementsystem.R;

public class ProfileActivity extends AppCompatActivity {

   private static final String TAG = ProfileActivity.class.getSimpleName();
   Button logout;
   ImageView profilePic;
   private static int PICK_IMAGE = 500;
   private Uri imagePath;
   private TextView username_profile,user_email;
   private FirebaseAuth firebaseAuth;
   private DatabaseReference databaseReference;
   private FirebaseUser firebaseUuser;
   String uId;
   protected void onCreate(Bundle savedInstanceState) {

       username_profile = findViewById(;
       user_email = findViewById(;
       //initializing firebase authentication object
       firebaseAuth = FirebaseAuth.getInstance();

       databaseReference = FirebaseDatabase.getInstance().getReference();

       Query q = databaseReference.child("users").orderByChild("email").equalTo(firebaseAuth.getCurrentUser().getEmail());
       Log.v(TAG, "My Query is here" + q);
       q.addListenerForSingleValueEvent(new ValueEventListener() {
           public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
               for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
                   if (postSnapshot.getValue() != null) {
                       Log.v(TAG, "DataSnaptshoot is here" + postSnapshot);
                       String value = dataSnapshot.getValue(String.class);

                       User user= dataSnapshot.child(uId).getValue(User.class);
                       String name = user.getName();
                       String email = user.getEmail();
                       username_profile.setText("User name: "+name);

           public void onCancelled(@NonNull DatabaseError databaseError) {

       //displaying logged in user name
      // username_profile = findViewById(;
       //user_email = findViewById(;

       //user_email.setText("Email: "+user.getEmail());

       logout = findViewById(;
       profilePic =findViewById(;

       logout.setOnClickListener(new View.OnClickListener() {
           public void onClick(View v) {
               //if logout is pressed
               if (v == logout) {
                   //logging out the user
                   //closing activity
                   //starting login activity
                   startActivity(new Intent(ProfileActivity.this, StudentLogin.class));

       profilePic.setOnClickListener(new View.OnClickListener() {
           public void onClick(View arg0) {


   private void  OpenGallery()
       Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);

   protected void onActivityResult(int requestCode, int resultCode, Intent data)
   { super.onActivityResult(requestCode,resultCode,data);

       if(resultCode == RESULT_OK && requestCode == PICK_IMAGE)
           imagePath = data.getData();

Saloon Keeper
Posts: 5344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a lot of code, which is barely legible without CODE tags. What does it do, what should it be doing instead, and what problems do you have making the required changes? TellTheDetails
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
global solutions you can do in your home or backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!