I Failed to add the object to the firebase database database. I tried the following code. But when this code executes
db.child("Users").setValue(person);
my application crashes
public class Person{ String fname; String lname; Person() {} Person(String fname,String lname) { this.fname = fname; this.lname = lname; } public String getFname() { return fname; } public String getLname() { return lname; } }
Here is ERROR.
11-20 15: 34: 57.762 2752-2752 / shazdroid.com.surveyapp E / AndroidRuntime: FATAL EXCEPTION: main Process: shazdroid.com.surveyapp, PID: 2752 com.google.firebase.database.DatabaseException: conflicting getters found for Name: isChangingConfigurations at com.google.android.gms.internal.zzamy $ zza. (Unknown source) at com.google.android.gms.internal.zzamy.zzj (Unknown source) at com.google.android.gms.internal.zzamy.zzca (Unknown source) at com.google.android.gms.internal .zzamy.zzch (Unknown source) at com.google.android.gms.internal.zzamy $ zza.zzci (Unknown source) at com.google.android.gms.internal.zzamy.zzca (Unknown source at com.google .android.gms.internal.zzamy.zzbz (Unknown source) at com.google.firebase.database.DatabaseReference.zza (Unknown source) at com.google.firebase.database.DatabaseReference.setValue (Unknown Source) at shazdroid.com.surveyapp.AddMember.savePerson (AddMember.java:207 ) at shazdroid.com.surveyapp.AddMember.access $ 000 (AddMember.java:37) at shazdroid.com.surveyapp.AddMember $ 6.onClick (AddMember.java:193) at android.view.View.performClick (View.java: 5610) on android.view.View $ PerformClick.run (View.java:22260) on android.os.Handler.handleCallback (Handler.java:751) on android.os.Handler.dispatchMessage (Handler.java:95) on android.os .Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6077) in java.lang.reflect.Method.invoke (native method) in com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main (Zygot eInit.java:755)
This is how I save the object.
private void savePerson() { suc.show(); Person person = new Person("shahbaz","ansari"); db.child("User").setValue(person) .addOnCompleteListener(AddMember.this, new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if(task.isSuccessful()) { suc.dismissWithAnimation(); suc = new SweetAlertDialog(AddMember.this,SweetAlertDialog.SUCCESS_TYPE); suc.setTitleText("Successful"); suc.setContentText("Saving data successful"); suc.setConfirmText("OK"); suc.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { sweetAlertDialog.dismissWithAnimation(); } }).show(); }else{ suc.dismissWithAnimation(); suc = new SweetAlertDialog(AddMember.this,SweetAlertDialog.ERROR_TYPE); suc.setTitleText("Failed"); suc.setContentText("Failed to save data"); suc.setConfirmText("Try Again"); suc.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { savePerson(); } }); suc.setCancelText("cancle"); suc.setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sweetAlertDialog) { sweetAlertDialog.dismissWithAnimation(); } }).show(); } } });
source share