Skip to content

Instantly share code, notes, and snippets.

@Bahaaib
Last active January 13, 2019 11:54
Show Gist options
  • Select an option

  • Save Bahaaib/4e316f557c1358b8dae5c179702e92de to your computer and use it in GitHub Desktop.

Select an option

Save Bahaaib/4e316f557c1358b8dae5c179702e92de to your computer and use it in GitHub Desktop.
Add new key-value pair child in Firebase DB
DatabaseReference testRef = mRef.child("test");
ref.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData currentData) {
currentData.child("my new child").setValue(1);
return Transaction.success(currentData);
}
@Override
public void onComplete(FirebaseError firebaseError, boolean committed, DataSnapshot currentData) {
//This method will be called once with the results of the transaction.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment