Answer the question
In order to leave comments, you need to log in
Firebase OutOfMemoryError at java.lang.String.?
Good afternoon, an application using data from a firebase database is crashing.
There is so much data, the document is obtained at 15 mb and is constantly growing, but how to implement all this then. I didn't quite understand how it works.
// onCreateView
databaseRef = FirebaseDatabase.getInstance().getReference().child("notifications");
Query queryToAll = databaseRef.orderByChild("to").equalTo("/topics/all");
Query queryToCity = databaseRef.orderByChild("to").equalTo("/topics/"+region);
Query queryToCodeAndRegion = databaseRef.orderByChild("code").equalTo(region+"_"+code);
queryToCodeAndRegion.addChildEventListener(this);
queryToAll.addChildEventListener(this);
queryToCity.addChildEventListener(this);
.........
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.hasChildren()){
FireBaseNotification notification = dataSnapshot.getValue(FireBaseNotification.class);
if (notification != null) {
notification.setId(dataSnapshot.getKey());
switch (notification.getTag()){
case WEB:
notificationsListWeb.add(notification);
notificationsGroup.put(WEB, notificationsListWeb);
break;
case ODIN_C:
notificationsList1c.add(notification);
notificationsGroup.put(ODIN_C, notificationsList1c);
break;
case MEscort:
notificationsListMEscort.add(notification);
notificationsGroup.put(MEscort, notificationsListMEscort);
break;
}
adapter.notifyDataSetChanged();
}
}
}
Answer the question
In order to leave comments, you need to log in
1) Try to put (for a quick solution) in the manifest android:largeHeap=true
2) Modernize the data structure in Firebase. The fact is that, according to its structure, it does not send you changes, but sends a snapshot of the latest changes - hence 15mb.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question