Skip to content Skip to sidebar Skip to footer

Android - Firebase Not Inserting Correctly

I have an application where I use a Google Maps MapView. With my map, I can insert markers which I save to the Firebase Realtime database. I have a FirebaseMarker class: public cla

Solution 1:

This is likely an issue with iterating over the markers map before the newest Marker has been added to it, so the maps then don't contain the same number of items.

I'd recommend creating both markers at the same time, something like:

StringmarkerId= userRef.push().getKey();

FirebaseMarkermarker=newFirebaseMarker(address, time, latitude, longitude);
PartialMarkerpartialMarker=newPartialMarker(address, time)

markers.put(markerId, marker);
partialMarkers.put(markerId, partialMarker);

This way, it's guaranteed that both maps have the same number of items.

Post a Comment for "Android - Firebase Not Inserting Correctly"