Retrieving data from firebase takes too much time
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
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 '18 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 '18 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 '18 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 '18 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 '18 at 11:32
|
show 4 more comments
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 '18 at 13:12
user9266642
asked Nov 21 '18 at 9:31
user9266642user9266642
55
55
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 '18 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 '18 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 '18 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 '18 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 '18 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 '18 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 '18 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 '18 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 '18 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 '18 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 '18 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 '18 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 '18 at 9:35
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 '18 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 '18 at 9:48
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 '18 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 '18 at 11:30
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 '18 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 '18 at 11:32
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 '18 at 11:32
|
show 4 more comments
3 Answers
3
active
oldest
votes
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 '18 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 '18 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 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 '18 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 '18 at 13:34
add a comment |
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 |
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 |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 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 '18 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 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 '18 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 '18 at 13:34
add a comment |
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 '18 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 '18 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 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 '18 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 '18 at 13:34
add a comment |
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 '18 at 9:44
war_Herowar_Hero
5,35723144
5,35723144
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 '18 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 '18 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 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 '18 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 '18 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 '18 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 '18 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 12:06
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 at 12:25
@user9266642 could you shed some more light on how the UI behaviour is there
– war_Hero
Nov 21 '18 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 '18 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 '18 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 '18 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 '18 at 13:34
add a comment |
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 |
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 |
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 '18 at 10:07
Prince_PrajwalPrince_Prajwal
214
214
add a comment |
add a comment |
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 |
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 |
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 '18 at 10:25
Mertcan ÇüçenMertcan Çüçen
568
568
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.
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 '18 at 9:34
Did you also try to use multiple threads? Did you try using Background Processing?
– dnsiv
Nov 21 '18 at 9:35
Try creating objects and store all your data inside it.
– Aryan Raj
Nov 21 '18 at 9:48
@Beasteca, yeah, I save it as byte code.
– user9266642
Nov 21 '18 at 11:30
@dnsiv ,can you give me an example? Please...
– user9266642
Nov 21 '18 at 11:32