I have an X DB that contains categories of companies and I want to get the children of the Categorias and send a copy to AllEmpresas
my firebase https://i.stack.imgur.com/ynbzg.jpg
I'm using this code but i don't know how to implement
private void copyRecord(DatabaseReference fromPath, final DatabaseReference toPath) {
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
toPath.setValue(dataSnapshot.getValue()).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isComplete()) {
Log.d(TAG, "Success!");
} else {
Log.d(TAG, "Copy failed!");
}
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {}
};
fromPath.addListenerForSingleValueEvent(valueEventListener);
}