last day (17 days later) » 

11:51 PM
0
Q: Can't read data from firebase realtime database. OnDataChange method is never triggered

Oleg GolomozAccording to google doc onDataChange method will be called with a snapshot of the data at this location. It will also be called each time that data changes. But in my case it's never called. I've read documentation about Firebase Realtime Database and even watched video like that. None code snipp...

 
Is doStuff() not getting called? Also is showLoading() getting called?
 
None of the methods is called
 
then init() is not getting called..
 
did it run with addValueEventListener?
 
where do u call the init() function?
 
11:51 PM
init() is called in onCreateView() method. showLoading() and adding of event listener are also called.
 
is data changed in the server ?
 
I was checking step by step. Everything was called before listener adding and after. But methods onDataChange() and onCancelled() weren't..
@average_developer I prefilled data in Firebase Console and then tried to read it in my Android app.
@faiizii I had the same result with addValueEventListener
 
did u see by trying to change the data manually in server then ?
can u add more code please ?
and also how u start the fragment
 
remove child("sales")
 
ok then you need to check is your firebase configure correctly with your app. or may be check internet connection
 
11:51 PM
@PeterHaddad I tried everything: getReference(), getReference("sales"), getReference().child("sales")
@faiizii I used firebase before and use for analytics, so I'm sure it's connected. Also I tried "Simulate connection" in console to check if it's possible to read data. Everything had success. Internet connection is also fine, because other fragments load internet data perfect.
@average_developer right now I can't show more code of my fragment, because haven't access to it. But I can say that fragment was loading without any problems, it was showing another internet data that I changed to firebase realtime database. This fragment is containing in ViewPager
 
theres nothing wrong with your code(posted) what is inside show loading?
 
@faiizii just something like progressBar.setVisibility(View.VISIBLE)
 
Isn't there any log in Logcat?
 
@sembozdemir nothing
onDataChange() is triggered when I add line ref.setValue("") But dataSnapshot hasn't anything to read then (because value is "")... Also, in my case is only needed to read data from prefilled Firebase Database.
 
if it is triggering onDataChange on seting the value at given ref then it also should get the prefilled Firebase on using addValueEventListener to get all the values. and test it with upgrading rules to write true.(just for testing)
 
11:51 PM
@faiizii Yep, I understand that i should show prefilled data without ref.setValue("") but have no idea why it doesn't. I also tested with different rules: true, false, "auth == null", "auth != null", all kind of combinations. Always the same result.
 
haha you are really in big trouble man :D. post the complete class code bro
 
sigh.. actually it's an empty Fragment except this init() method and few methods of lifecycle... I didn't add anything else, because stucked at this place. I can post complete code only at evening...
@faiizii Is there another way to check if my Firebase Database configuration is correct?
 

  last day (17 days later) »