Last active
January 13, 2019 11:54
-
-
Save Bahaaib/4e316f557c1358b8dae5c179702e92de to your computer and use it in GitHub Desktop.
Add new key-value pair child in Firebase DB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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