SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I have an app where save data and retrieve also but the problem is when I saving those data , some of those data saved successfully but some others not so it got crushed for the onDataChange method as it found data is changing but can not find some of others.
  2.  
  3.  
  4. private void SaveIntoFirebase()
  5. {
  6. DatabaseReference reference= FirebaseDatabase.getInstance().getReference().child(DBConst.AppointmentShedule).child("01"/*FirebaseAuth.getInstance().getCurrentUser().getUid()*/).child(HospitalNameEt.getText().toString());
  7.         reference.child(DBConst.AvailableDay).setValue(SelectDayTv.getText().toString());
  8.         reference.child(DBConst.AppointmentTime).setValue(StartingTimeEt.getText().toString()+"~"+EndingTimeEt.getText().toString());
  9.         reference.child(DBConst.UnavaiableSDate).setValue(StaringDateEt.getText().toString());
  10.         reference.child(DBConst.UnavaiableEDate).setValue(EndingDateEt.getText().toString())
  11.                 .addOnCompleteListener(new OnCompleteListener<Void>() {
  12.                     @Override
  13.                     public void onComplete(@NonNull Task<Void> task)
  14.                     {
  15.                         if (task.isComplete())
  16.                         {
  17.                             SaveIntoHospitalDirectory();
  18.                         }
  19.                     }
  20.                 });
  21.      
  22. String HospitalName=dataSnapshot1.getKey();
  23.                         String AvaialableDay=dataSnapshot.child(HospitalName).child(DBConst.AvailableDay).getValue().toString();
  24.                         String AppointmentTime=dataSnapshot.child(HospitalName).child(DBConst.AppointmentTime).getValue().toString();
  25.                         String UnavaiableSDate=dataSnapshot.child(HospitalName).child(DBConst.UnavaiableSDate).getValue().toString();
  26.                         String UnavaiableEDate=dataSnapshot.child(HospitalName).child(DBConst.UnavaiableEDate).getValue().toString();
  27.                         arrayList.add(new AppointmentDataModel("01"/*UID*/,HospitalName,AvaialableDay,AppointmentTime,UnavaiableSDate,UnavaiableEDate));
  28.  
  29.  
  30.                         AppointmentDataModel dataModel=dataSnapshot1.getValue(AppointmentDataModel.class);
  31.                         arrayList.add(dataModel);
  32.                     }
  33.                     adapter=new AppointmentDataAdapter(activity,arrayList);
  34.                     listView.setAdapter(adapter);
  35.                 }
  36.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top