Home > Back-end >  unable to connect to firebase realtime database andriod studio
unable to connect to firebase realtime database andriod studio

Time:02-28

I am having some trouble connecting to firebase's realtime database.

I am getting this error: compilation error

even though my database url I am referencing is correct. This is my code:

FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReferenceFromUrl("https://i021task-b5626-default-rtdb.europe-west1.firebasedatabase.app/");

and i got the URL from this:

database

Can someone please help me figure out why this is? I would greatly appreciate it. Thank you

CodePudding user response:

You need to pass the database URL to the instance call:

FirebaseDatabase database = FirebaseDatabase.getInstance("https://i021task-b5626-default-rtdb.europe-west1.firebasedatabase.app/");
DatabaseReference myRef = database.getReference();

Also see: How to change firebase URL for FirebaseReference in Android Studio? and React native firebase realtime database reference return null

  • Related