Retrieving data from firebase takes too much time
up vote
1
down vote
favorite
I think this is a crazy question but I'm new to firebase...Here is my problem...
I want to retrieve firebase data to textview, imageview and listview! this is my example database structure..it has many other nodes like this 😁
https://i.stack.imgur.com/JURr3.png
So, I add username to a textview, profile photo to imageview, birthdate to a textview and there are many other nodes like messages and other usernames(in an activity).It's ok but the problem is "it takes to much time to retrieve data to each view and then it shows all the data at the same time"..I mean it don't show each data simultaneously after loading but show all requested data to all views after loading. What I want is a view after a view loading and showing...😢😢
I don't know how to explain my problem and how to call it as I have bad Eng skill...😭😭
Here is UI of that activity after fetching data.(Birthdate and some data haven't added yet). https://i.stack.imgur.com/GRX0O.png This is the photo while retrieving with default image and text. https://i.stack.imgur.com/iEhv9.png
android
|
show 4 more comments
up vote
1
down vote
favorite
I think this is a crazy question but I'm new to firebase...Here is my problem...
I want to retrieve firebase data to textview, imageview and listview! this is my example database structure..it has many other nodes like this 😁
https://i.stack.imgur.com/JURr3.png
So, I add username to a textview, profile photo to imageview, birthdate to a textview and there are many other nodes like messages and other usernames(in an activity).It's ok but the problem is "it takes to much time to retrieve data to each view and then it shows all the data at the same time"..I mean it don't show each data simultaneously after loading but show all requested data to all views after loading. What I want is a view after a view loading and showing...😢😢
I don't know how to explain my problem and how to call it as I have bad Eng skill...😭😭
Here is UI of that activity after fetching data.(Birthdate and some data haven't added yet). https://i.stack.imgur.com/GRX0O.png This is the photo while retrieving with default image and text. https://i.stack.imgur.com/iEhv9.png
android
Did you save the photo of the imageview as bytes or you store just file path of the photo? If you save the whole image as bytes, it is normal to take longer time for the system to process all this data.
– Beasteca
Nov 21 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 at 11:32
|
show 4 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I think this is a crazy question but I'm new to firebase...Here is my problem...
I want to retrieve firebase data to textview, imageview and listview! this is my example database structure..it has many other nodes like this 😁
https://i.stack.imgur.com/JURr3.png
So, I add username to a textview, profile photo to imageview, birthdate to a textview and there are many other nodes like messages and other usernames(in an activity).It's ok but the problem is "it takes to much time to retrieve data to each view and then it shows all the data at the same time"..I mean it don't show each data simultaneously after loading but show all requested data to all views after loading. What I want is a view after a view loading and showing...😢😢
I don't know how to explain my problem and how to call it as I have bad Eng skill...😭😭
Here is UI of that activity after fetching data.(Birthdate and some data haven't added yet). https://i.stack.imgur.com/GRX0O.png This is the photo while retrieving with default image and text. https://i.stack.imgur.com/iEhv9.png
android
I think this is a crazy question but I'm new to firebase...Here is my problem...
I want to retrieve firebase data to textview, imageview and listview! this is my example database structure..it has many other nodes like this 😁
https://i.stack.imgur.com/JURr3.png
So, I add username to a textview, profile photo to imageview, birthdate to a textview and there are many other nodes like messages and other usernames(in an activity).It's ok but the problem is "it takes to much time to retrieve data to each view and then it shows all the data at the same time"..I mean it don't show each data simultaneously after loading but show all requested data to all views after loading. What I want is a view after a view loading and showing...😢😢
I don't know how to explain my problem and how to call it as I have bad Eng skill...😭😭
Here is UI of that activity after fetching data.(Birthdate and some data haven't added yet). https://i.stack.imgur.com/GRX0O.png This is the photo while retrieving with default image and text. https://i.stack.imgur.com/iEhv9.png
android
android
edited Nov 21 at 13:12
asked Nov 21 at 9:31
user9266642
135
135
Did you save the photo of the imageview as bytes or you store just file path of the photo? If you save the whole image as bytes, it is normal to take longer time for the system to process all this data.
– Beasteca
Nov 21 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 at 11:32
|
show 4 more comments
Did you save the photo of the imageview as bytes or you store just file path of the photo? If you save the whole image as bytes, it is normal to take longer time for the system to process all this data.
– Beasteca
Nov 21 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 at 11:32
Did you save the photo of the imageview as bytes or you store just file path of the photo? If you save the whole image as bytes, it is normal to take longer time for the system to process all this data.
– Beasteca
Nov 21 at 9:34
Did you save the photo of the imageview as bytes or you store just file path of the photo? If you save the whole image as bytes, it is normal to take longer time for the system to process all this data.
– Beasteca
Nov 21 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 at 9:35
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 at 9:48
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 at 11:30
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 at 11:32
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 at 11:32
|
show 4 more comments
3 Answers
3
active
oldest
votes
up vote
0
down vote
Not sure how you are feting data, ideally this should be the set of steps that you should be doing.
1) Fetch all the data(all children data as well) from that node and put it in a list.
2) Pass the data to a RecyclerView and populate it this was there wont be any lag.
This is an example code to fetch all the child nodes
myQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
// TODO: Add to list to send it to recyclerview
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
});
Hopefully, this will help you.
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
add a comment |
up vote
0
down vote
Step 1 :
Use Sqlite as a local database to store your data as well along wid maybe if u r using Firebase Realtime Database. Everytime a data is loaded for the first time , it will also be stored in the local database. So the next time when u open the app, u would see the results that u r expecting !
Step 2:
If u r using Firebase Realtime Database as a backend, make use of the Offline Data Handling feature which firebase provides. This too can solve your problem !
add a comment |
up vote
0
down vote
My personal advice is not to reach firebase data directly from client because of possible authentication and performance problems due to unintented implementation and usage of firestore api.
Instead, use Firebase cloud functions and write a service for what you need. To call those services from the app, you can use Firebase calls. You may suffer from cold boot but you can solve it with a warm up process ex. call those functions every minute with a cron job that can be set via cron-job.org
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Not sure how you are feting data, ideally this should be the set of steps that you should be doing.
1) Fetch all the data(all children data as well) from that node and put it in a list.
2) Pass the data to a RecyclerView and populate it this was there wont be any lag.
This is an example code to fetch all the child nodes
myQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
// TODO: Add to list to send it to recyclerview
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
});
Hopefully, this will help you.
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
add a comment |
up vote
0
down vote
Not sure how you are feting data, ideally this should be the set of steps that you should be doing.
1) Fetch all the data(all children data as well) from that node and put it in a list.
2) Pass the data to a RecyclerView and populate it this was there wont be any lag.
This is an example code to fetch all the child nodes
myQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
// TODO: Add to list to send it to recyclerview
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
});
Hopefully, this will help you.
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
add a comment |
up vote
0
down vote
up vote
0
down vote
Not sure how you are feting data, ideally this should be the set of steps that you should be doing.
1) Fetch all the data(all children data as well) from that node and put it in a list.
2) Pass the data to a RecyclerView and populate it this was there wont be any lag.
This is an example code to fetch all the child nodes
myQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
// TODO: Add to list to send it to recyclerview
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
});
Hopefully, this will help you.
Not sure how you are feting data, ideally this should be the set of steps that you should be doing.
1) Fetch all the data(all children data as well) from that node and put it in a list.
2) Pass the data to a RecyclerView and populate it this was there wont be any lag.
This is an example code to fetch all the child nodes
myQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot: dataSnapshot.getChildren()) {
// TODO: Add to list to send it to recyclerview
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
});
Hopefully, this will help you.
answered Nov 21 at 9:44
war_Hero
5,16822944
5,16822944
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
add a comment |
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
No...the views are not in a cluster.The username is in the toolbar.The birthdate is in a dialog..so how to fetch them?
– user9266642
Nov 21 at 11:45
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
still, the same way looks like there is some logic involved where you show the data for each item(user in your case) in a different screen
– war_Hero
Nov 21 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 at 12:25
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
I have added. OnActivityCreate, it retrieve all requested data and than show in views.I want is show one data after retrieve and another one.eg. if it retrieve username first, show it and go on the others.But my activity don't show one after one but show all in the same time😢.So I have to wait without seeing any data in my views...😢😢
– user9266642
Nov 21 at 13:11
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
then this has to be done before the navigation, and also persist your data locally and update the DB in background
– war_Hero
Nov 21 at 13:34
add a comment |
up vote
0
down vote
Step 1 :
Use Sqlite as a local database to store your data as well along wid maybe if u r using Firebase Realtime Database. Everytime a data is loaded for the first time , it will also be stored in the local database. So the next time when u open the app, u would see the results that u r expecting !
Step 2:
If u r using Firebase Realtime Database as a backend, make use of the Offline Data Handling feature which firebase provides. This too can solve your problem !
add a comment |
up vote
0
down vote
Step 1 :
Use Sqlite as a local database to store your data as well along wid maybe if u r using Firebase Realtime Database. Everytime a data is loaded for the first time , it will also be stored in the local database. So the next time when u open the app, u would see the results that u r expecting !
Step 2:
If u r using Firebase Realtime Database as a backend, make use of the Offline Data Handling feature which firebase provides. This too can solve your problem !
add a comment |
up vote
0
down vote
up vote
0
down vote
Step 1 :
Use Sqlite as a local database to store your data as well along wid maybe if u r using Firebase Realtime Database. Everytime a data is loaded for the first time , it will also be stored in the local database. So the next time when u open the app, u would see the results that u r expecting !
Step 2:
If u r using Firebase Realtime Database as a backend, make use of the Offline Data Handling feature which firebase provides. This too can solve your problem !
Step 1 :
Use Sqlite as a local database to store your data as well along wid maybe if u r using Firebase Realtime Database. Everytime a data is loaded for the first time , it will also be stored in the local database. So the next time when u open the app, u would see the results that u r expecting !
Step 2:
If u r using Firebase Realtime Database as a backend, make use of the Offline Data Handling feature which firebase provides. This too can solve your problem !
answered Nov 21 at 10:07
Prince_Prajwal
214
214
add a comment |
add a comment |
up vote
0
down vote
My personal advice is not to reach firebase data directly from client because of possible authentication and performance problems due to unintented implementation and usage of firestore api.
Instead, use Firebase cloud functions and write a service for what you need. To call those services from the app, you can use Firebase calls. You may suffer from cold boot but you can solve it with a warm up process ex. call those functions every minute with a cron job that can be set via cron-job.org
add a comment |
up vote
0
down vote
My personal advice is not to reach firebase data directly from client because of possible authentication and performance problems due to unintented implementation and usage of firestore api.
Instead, use Firebase cloud functions and write a service for what you need. To call those services from the app, you can use Firebase calls. You may suffer from cold boot but you can solve it with a warm up process ex. call those functions every minute with a cron job that can be set via cron-job.org
add a comment |
up vote
0
down vote
up vote
0
down vote
My personal advice is not to reach firebase data directly from client because of possible authentication and performance problems due to unintented implementation and usage of firestore api.
Instead, use Firebase cloud functions and write a service for what you need. To call those services from the app, you can use Firebase calls. You may suffer from cold boot but you can solve it with a warm up process ex. call those functions every minute with a cron job that can be set via cron-job.org
My personal advice is not to reach firebase data directly from client because of possible authentication and performance problems due to unintented implementation and usage of firestore api.
Instead, use Firebase cloud functions and write a service for what you need. To call those services from the app, you can use Firebase calls. You may suffer from cold boot but you can solve it with a warm up process ex. call those functions every minute with a cron job that can be set via cron-job.org
answered Nov 21 at 10:25
Mertcan Çüçen
468
468
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408940%2fretrieving-data-from-firebase-takes-too-much-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you save the photo of the imageview as bytes or you store just file path of the photo? If you save the whole image as bytes, it is normal to take longer time for the system to process all this data.
– Beasteca
Nov 21 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 at 11:32