0

I am trying to write a Spot object to my Firebase database. All was good an well until I added an ArrayList<> attribute to the Spot class. Now I can no longer write Spot object to the database and when I try, my app just.. stops. No crash, so I don't get any error feedback in the log :/

Here is my writing code:

public void writeSpot(Spot spot, AddSpotContract.RequiredModelOps subscriber) {
    Log.i("DBGR", "writing spot");
    getReference().child(spot.getId()).setValue(spot);
    Log.i("DBGR", "what is going on??");//if Spot object has an ArrayList<Uri> attribute, this is never reached
    subscriber.onSpotWritten();
}

So does anybody know why I can't write an object with an ArrayList<> attribute to the database? I've tried with an array, but that isn't supported (at least in that case I get the feedback to tell me that).

Thanks a lot :)

EDIT: I found the answer.

It actually had nothing to do with the ArrayList, the issue came from trying to write a Uri to the database, as it isn't a supported class (see error "java.lang.StackOverflowError:" when try to save object in Firebase Database)

1 Answer 1

1

In order to write data objects to your Firebase database, in stead of using a List, use a Map. If you have also in your pojo an Map field, change it to a Map.

Hope it helps.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Alex, your solution didn't work but it caused an error that I could actually use :)
Yep, im not sure what the etiquette is to answer your own question, so I just made an edit. Thanks for the assist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.