I am having some trouble connecting to firebase's realtime database.
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:
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