So I'm having trouble with retrieving data from my database. I think the problem lies in the return statement.
When I run the app the debug text where the flatID should be shown is blank. I know for sure that the data is on the database so that isn't the issue.
I'm still very new to Java and programming in general, thanks for your help and your patience :) The code is as follows.
flatID = readFlatID();
debug1.setText(flatID);
public String readFlatID(){
String uid = mAuth.getCurrentUser().getUid().toString();
mDatabase.child("Users").child(uid).child("Flat")
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
flat = dataSnapshot.getValue().toString();
Toast.makeText(getApplicationContext(),"Data Read Successfully",Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return flat;
}