I connected my android app to google's realtime database. (This is for school and I'm very, very new at all of this app development stuff.) And I was wondering why my log.d() method outputs it's contents to the logcat in the wrong order. I don't think it's a major issue and I can probably work around it but I'm just curious about why it executes like this or if it's something wrong with my code I have to fix.
Resident Page:
public class ResidentPage extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
....
basicReadWrite();
MethodsFromOtherClass.output();
return view;
}
...
public void basicReadWrite(){
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("second message");
myRef.setValue("Hello again, World!");
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String value = dataSnapshot.getValue(String.class);
Log.d("ResidentPage", "Value is: " + value);
}
@Override
public void onCancelled(DatabaseError error) {
Log.w("ResidentPage", "Failed to read value.", error.toException());
}
});
}
}
Methods from other class:
public class MethodsFromOtherClass {
public static void output(){
Log.d("ResidentPage", "Called from another class");
}
}
Logcat:
D/ResidentPage: Called from another class
D/ResidentPage: Value is: Hello again, World!