Working on saving user objects to my Firebase Database, but cannot seem to save any complex custom objects.
protected DatabaseReference userRef = FirebaseDatabase.getInstance().getReference().child("users");
/.../
User user = new User();
User.setGroups(new ArrayList<String>());
User.setCurrentlyReading(new ArrayList<String>());
userRef.child(userId).setValue(user);
I can save data when I swap out the user in setValue with a string, so I know at least my connection works and I can at least write something to the database.
Any help would be much appreciated.
Update: Adding details on user object
@IgnoreExtraProperties
public class User {
private List<String> groups;
private List<String> currentlyReading;
public User(){}
public List<String> getGroups() {
return books;
}
public void setGroups(List<String> groups) {
this.groups = groups;
}
public List<String> getCurrentlyReading() {
return currentlyReading;
}
public void setCurrentlyReading(List<String> currentlyReading) {
this.currentlyReading = currentlyReading;
}
}
User
look like? Firebase can read/write plain old java objects. See the docs for some examples. firebase.google.com/docs/database/android/save-data