Invalid Firebase Path Error While Fetching Database
I am using Firebase for both authentication and realtime database. My authentication code was successfully run also my enter value to database code also run, but when I am coding f
Solution 1:
I think the answer is quite obvious you don't need to specific the url
because app is already link to the database
when you set up the project
just change from
DatabaseReference reference = database.getReference("https://korsae03ae.firebaseio.com/");
to
DatabaseReference reference = database.getReference();
Then it should work
Solution 2:
Url of your database is in your google-services.json file. By firebase docs https://firebase.google.com/docs/database/admin/retrieve-data to read data, you can do the following:
finalFirebaseDatabasedatabase= FirebaseDatabase.getInstance();
DatabaseReferenceref= database.getReference("posts");
// Attach a listener to read the data at our posts reference
ref.addValueEventListener(newValueEventListener() {
@OverridepublicvoidonDataChange(DataSnapshot dataSnapshot) {
Postpost= dataSnapshot.getValue(Post.class);
System.out.println(post);
}
@OverridepublicvoidonCancelled(DatabaseError databaseError) {
System.out.println("The read failed: " + databaseError.getCode());
}
});
Solution 3:
Instead of using getReferance use, getReferanceFromUrl. and in your case: database.getReference.child("posts");
Post a Comment for "Invalid Firebase Path Error While Fetching Database"