I don't quite sure what when wrong, but I have check the variable name is the same whether it is in a layout xml and the java class, but when I run the apps it give me error which said that
java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.example.g.Model.Ps.ps_name' on a null object reference
I have declare the variable btw.
firebaseAuth = FirebaseAuth.getInstance();
currentUser = firebaseAuth.getCurrentUser();
psID = currentUser.getUid();
databaseReference = FirebaseDatabase.getInstance().getReference("PersonalShopper").child(firebaseAuth.getUid());
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
PersonalShopper ps = dataSnapshot.getValue(PersonalShopper.class);
psname.setText(ps.ps_name);
pspassword.setText(ps.ps_password);
psemail.setText(ps.ps_email);
}
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="13dp"/>
<EditText
android:id="@+id/psname"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Password"
android:textSize="13dp"/>
<EditText
android:id="@+id/pspassword"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email"
android:textSize="13dp"/>
<TextView
android:id="@+id/psemail"
android:hint="email@gmail.com"
android:layout_width="match_parent"
android:layout_height="wrap_content" />