You cannot change the name of a key, let's say ricksanchez to something else. There is no API for doing that. If you want to change the name of a key, you definitely need to copy that particular object to another location, change the name and then delete the old record. But to somply change the name of key is not possible in Firebase.
Edit: According to your comment, please use the following method to copy a record from a location to another.
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);
}