6
votes

I am trying to send test data to my firebase database. In android studio I chose Tools > Firebase > Assistant FB > Realtime Database > Connect your app to Firebase(Connected) > Add the realtime database to your app(dependencies set up correctly).

Then I add sample code in my activity:

FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");

myRef.setValue("Hello, World!");

I set the rules in firebase:

{
  "rules": {
    ".read": true,
    ".write": true
  }
}

But the data does not add to the realtime database. Maybe I need some permission? In logcat AS nothing error

UPD:

not add data

    private DatabaseReference mDatabase;
 mDatabase = FirebaseDatabase.getInstance().getReference();
        mDatabase.child("message").setValue("Hello, World!");

not add data too

Message mess = new Message("hello");
        mDatabase.child("message").setValue(mess);

class Message

@IgnoreExtraProperties
public class Message {

    public String mes;

    public Message(){}

    public Message(String mes) {this.mes = mes;}

}
2
do you have a root node in the firebase database console? Did you click get started in the firebase database console? - Peter Haddad
@PeterHaddad thanks for your comment. Yes, i have http://take.ms/nCFEN - r1299597
add data in the firebase console by clicking + and then adding name and value does it work? - Peter Haddad
@PeterHaddad yes, data is add when i press +. Then i check, and i add data from hurl.it http://take.ms/nzHKx I cant understand why from android app data not add - r1299597
clean>build the project and add this under onCreate private DatabaseReference mDatabase; mDatabase = FirebaseDatabase.getInstance().getReference(); mDatabase.child("message").setValue("Hello, World!");. Debug the app on a device and you should get message:hello, World under root node - Peter Haddad

2 Answers

0
votes

Check and ensures your are submitting data to firebase else firebase will not write to your database.

0
votes

I had the same problem as yours. Please go again to Tools -> Firebase -> Realtime Database -> and make sure that you Firebase is connected and Realtime Database is set up. Hope it helps.)