Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

unable to connect to firebase realtime database andriod studio

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading