I have my read-only data in firebase, It's about 50KB.
And I need the complete data on app startup. For that I wrote the following code in my onCreate method
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference();
Log.i("FIREBASE", "Before Firebase Call");
myRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i("FIREBASE", "Call Completed");
// do my work i.e build my UI
}
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(context, "Please Check your Internet connection", Toast.LENGTH_LONG);
}
});
Now my problem is, Firebase is taking more than 4 seconds getting the data. In the above code there is 4 seconds gap between both log statements i.e 'Before Firebase Call' & 'Call Completed'
I even tested in real devices, even there its taking minimum 3 seconds.
Am I missing something here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…