Android HashMap or POJO (Plain Old Java Object). iOS Dictionary. • Key must be String. Value can be primitive types and Android HashMap or iOS Dictionary. • Android : Firebase handle Object " JSON. • Use @Exclude to exclude field.
reference to auto generated child • Child has unique ID & sorted by date • like append array • runTransaction( Transaction.Handler ) • multiple concurrent operations • keep data from being corrupted • e.g counter
Integer value = (Integer) currentData.getValue(); // must handle null if (value == null) { value = 0; } currentData.setValue( value + 1 ); return Transaction.success(currentData); //we can also abort by calling Transaction.abort() } @Override public void onComplete(FirebaseError firebaseError, boolean committed, DataSnapshot currentData) { //This method will be called once with the results of the transaction. } });
callback. • called when operation is completed dotaRef.updateChildren(updatedChildren, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { } });