skip to Main Content

I am trying to pass data from androidX to Firebase, it was working perfectly but now it doesn’t work. I am attaching screenshots for the better understanding.

private FirebaseDatabase database = FirebaseDatabase.getInstance();
private DatabaseReference myRef = database.getReference().child("Users");

Main activity:

mainActivity

enter image description here

More annoying screenshots of text:

secondphoto

Also I try it with URL inside the getInstance() function
but that doesn’t work, either.

private FirebaseDatabase database = FirebaseDatabase.getInstance("URL");
private DatabaseReference myRef = database.getReference().child("Users");

2

Answers


  1. Chosen as BEST ANSWER

    Path is needed.

    Like this:

    FirebaseDatabase database = FirebaseDatabase.getInstance(
        "https://database-c249f-default-rtdb.firebaseio.com/");
    

  2. When FirebaseDatabase.getInstance() does require an URL, this means that you have to run FirebaseApp.initializeApp(MainActivity.this) first, in order to initialize the FirebaseApp
    … unless wanting to connect to another RTDB URL.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search