I have tried using the following if statement, but the only values that it returns are the URL for my image link:
reference.child("Businesses").child(firebaseUser.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.exists())
{
String businessName = snapshot.getValue().toString();
editTextBusinessName.setText(businessName);
String businessAbout = snapshot.getValue().toString();
editTextAbout.setText(businessAbout);
String businessAddress = snapshot.getValue().toString();
editTextAddress.setText(businessAddress);
String businessContactPerson = snapshot.getValue().toString();
editTextContactPerson.setText(businessContactPerson);
String businessContactNumber = snapshot.getValue().toString();
editTextContactNumber.setText(businessContactNumber);
}
2
Answers
I am not sure if this was the right way to solve my problem, but it worked : My database structure was Businesses -> userID -> businessName -> businessAbout. I changed it so all the children will fall under just userID, that included businessName.
Thank you guys :)
If your
firebaseUser.getUid()
returnsNN3ikr...
, then youronDataChange
should already be called with the correct snapshot according to your screenshot.You can get the values of the individual properties with: