3

I'm working on an android application, i'm trying to upload my data into the firebase Realtime Database , but it is not showing up there everything is set correctly, all dependencies are set correctly, application is working properly, there are no errors!. but the problem is data is not getting updated into the Realtime database.

enter image description here

buttonC.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FirebaseDatabase database = FirebaseDatabase.getInstance();
            DatabaseReference myRef = database.getReference("message");

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

        }
    });
Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
  • Did you check if your code is runing at all? You won't belive how often we see such things happen here. Make a print so the console when the code runs to we can get that of your debuging list. – Tarik Huber Jun 29 '21 at 06:40
  • make sure you are making an authenticated request. – Faiizii Awan Jun 29 '21 at 07:03
  • Have you tried to attach a complete listener to the setValue() operation? Are you getting any errors? Please respond with @AlexMamo – Alex Mamo Jun 29 '21 at 08:47
  • Have you defined your database URL when you initiate Firebase? – DIGI Byte Jun 29 '21 at 10:26

1 Answers1

8

firebaser here

If you downloaded the google-services.json before you created the database, the SDK won't be able to determine the correct database URL - since your database instance is not in the default region.

You have two options to fix it in that case:

  1. You can specify the full database URL in the call to getInstance() like this: FirebaseDatabase.getInstance("your database URL").getReference()
  2. You can download an updated google-services.json after you created the database, and make sure you app uses that file.

It's pretty easy to miss this condition right now, as the relevant warning is logged as a debug message. We're working on surfacing the message more explicitly, but in the meantime the above should also work.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807