Data is not inserted in firebase

211 views
Skip to first unread message

Saboor Siddique

unread,
Apr 20, 2021, 8:02:49 AM4/20/21
to Firebase Google Group

Hello to all! I have been Using google firebase with my android apps for more than 2 years. Today while developing a new app I am facing a weird problem. I set up my firebase project on Google firebase Console successfully. I write the code to push data on firebase successfully.
But the problem is that No data inserted in firebase and no Error occurs in the console. I searched online a lot but all in vain. I am pasting Screen shot of my firebase console, database rules and my source code. Kindly guide me.

// source code:

database = FirebaseDatabase.getInstance(); 

dealer_ref = database.getReference("reg_requests"); 

 btnSignup.setOnClickListener(new View.OnClickListener()

{ @Override public void onClick(View v){

Dealer dealer = new Dealer();

dealer.setId(ed.getText().toString());

dealer.setMac(getMacAddress(LoginActivity.this));

dealer.setRegistered("no"); 

 dealer_ref.push().setValue(dealer);

}

});






rules shot.PNG
firebaseshot.PNG

Andreas B

unread,
Apr 21, 2021, 5:52:50 AM4/21/21
to Firebase Google Group
Hi. It's a bit hard to tell from just that code snippet, but the first thing I would check first is what dealer_ref.push().setValue(dealer); actually does. Calling setValue(null) will delete all data at the location - or, in your case, probably not write anything in the first place.

https://firebase.google.com/docs/reference/android/com/google/firebase/database/DatabaseReference#setValue(java.lang.Object) lists some constraints that your Dealer class needs to satisfy. Is this the case? Perhaps try setting a primitive value first (like setValue("foobar")) to rule out any other problems.

Reply all
Reply to author
Forward
0 new messages