I am doing a push action with setValue.
mFirebaseDatabaseReference.child("loccheck").push().setValue(cloc);
How do I retrieve the unique string created? P.S. I know how to do it with a push without setValue:
String key = mDatabase.child("posts").push().getKey();
You can get the unique key after you push like
DatabaseReference newDatabaseReference = mDatabaseReference.child("loccheck").push();
newDatabaseReference.getKey();
or with setValue()
mDatabaseReference.child("loccheck")
.push()
.setValue(cloc, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError,
DatabaseReference databaseReference) {
String uniqueKey = databaseReference.getKey();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With