DriverDatabase.class
AddInfoDriver.class
DriverProfile.class
In DriverDatabase.class
I have set(fName, lName .... and other fields.). Also, put {get; and set;}
for those attribtues.
In AddInfoDriver.class
I have referenced FirebaseDatabase
and DriverDatabase.class
so that, whenever a user fills those edittexts, it saves to Firebase Database.
The Problem is: I cannot retrieve those 5 Edittext values in DriverProfile.class
below is the piece of code for retrieving.
public class DriverProfile extends Fragment {
@BindView(R.id.btn_save) Button btnsave;
@BindView(R.id.edtx_DoB) EditText edtxdob;
@BindView(R.id.edtx_fname) EditText edtx_fname;
@BindView(R.id.edtx_lname) EditText edtx_lname;
@BindView(R.id.spinner_type) Spinner spn_type;
@BindView(R.id.edtx_number) EditText edtx_number;
private DatabaseReference driverfname, driverlname;
public DriverProfile() {
//Constructed is required
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my_profile, container, false);
ButterKnife.bind(this, view);
driverfname = FirebaseDatabase.getInstance().getReference().child("Drivers").child("fname");
driverlname = FirebaseDatabase.getInstance().getReference().child("Drivers").child("lname");
driverfname.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
edtx_fname.setText(dataSnapshot.getValue(String.class));
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Didnt write all edittext codes, just see my ValueEventListener
for fname of Driver. it is not displaying data when saved by driver in a child("Drivers")