Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

android - Sum firebase data efficiently up

I have an app where I have up to a few thousand entries in a firebase table. Now someone is connecting to this table and I need to count and sum these items up.

-itemlist
|
--1
  |-x:2
--2
  |-x:4

and so on. A user can connect at any time (meaning he never saw this table before) and another user can change some value at any given time or add values.

Now if I try and add a ValueEventListener to "itemlist" it works if there is no new data but as soon as I connect to a new database with 1000 entries or so the listener calls for every one of these 1000 entries.

I tried with onChildlistener but this calls the on ChildItem added for every item extra on the first time. This takes over 2 minutes sometimes.

Is there a way to get the whole database once, calculate it and then only listen for changes?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...