0

So that's what my database looks like: enter image description here

And here's my code:

DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
    mDatabase.child("add_first_element").get().addOnCompleteListener(task -> {
        if (!task.isSuccessful()) {
            Log.e("firebase", "Error getting data", task.getException());
        }
        else {
            Log.d("firebase", String.valueOf(task.getResult().getValue()));
        }
    });

This is what logcat tells me:

Firebase Database connection was forcefully killed by the server. Will not attempt reconnect. Reason: Database lives in a different region. Please change your database URL to https://verticalrecyclerview-default-rtdb.europe-west1.firebasedatabase.app

How do I solve this problem?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
kirvel
  • 629
  • 1
  • 6
  • 13

1 Answers1

1

The error message suggests that your Firebase Database is located in a different region than the default region of your Firebase project. To resolve this issue, you need to change the database URL to the correct region-specific URL.

In your case, you need to change the database URL to https://verticalrecyclerview-default-rtdb.europe-west1.firebasedatabase.app. To do this, you can update your FirebaseDatabase.getInstance() call with the correct URL:

FirebaseDatabase.getInstance("https://verticalrecyclerview-default-rtdb.europe-west1.firebasedatabase.app").getReference();

This should resolve the error and allow you to connect to your Firebase Database.

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