I have been through the same problem a while ago implementing a feature for a client.
How I solved it.
Simply storing the admin UID into shared preferences, so, each time I created a new user within the admin, I assigned that user the UID of the admin who created it.
Also, if you log in with another admin, just overwrite the current UID that is in sharedprefs with the current admin uid that logged in.
Doing this you can keep creating and storing users into the admin ID
If I find the code of that implementation, I will be posting it here
EDIT
Found a little bit of the code that can help you understand
for example, to create a new user
public void cargarPacienteFirebase(String email, String password, final String nombre, final String apellido, final Dialog mDialog) {
SharedPreferences prefs = mContext.getSharedPreferences("ADMINUID", Context.MODE_PRIVATE);
final String adminUID = prefs.getString("adminuid", "defaultValue");
final UserModel userModel = new UserModel();
userModel.setNombre(nombre);
userModel.setApellido(apellido);
final ProgressDialog pd = new ProgressDialog(mContext);
pd.setMessage("Estamos cargando su paciente...");
pd.setCancelable(false);
pd.show();
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
pd.dismiss();
final String pacienteID = task.getResult().getUser().getUid();
SharedPreferences settings = mContext.getSharedPreferences("PACIENTEUID", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putString("pacienteuid", pacienteID);
editor.apply();
Map<String, Object> mapUsuario = new HashMap<>();
mapUsuario.put("nombre", userModel.getNombre());
mapUsuario.put("apellido", userModel.getApellido());
mapUsuario.put("pregunta", 0);
mDatabase.child("Test").child(adminUID).child("pacientes").child(pacienteID).updateChildren(mapUsuario);
Map<String, Object> userLookUp = new HashMap<>();
userLookUp.put(pacienteID, adminUID);
mDatabase.child("Test").child("userLookup").updateChildren(userLookUp);
Toast.makeText(mContext, "Succefully added a new user", Toast.LENGTH_SHORT).show();
mDialog.dismiss();
} else {
pd.dismiss();
Toast.makeText(mContext, "E-mail or password invalid",
Toast.LENGTH_SHORT).show();
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(mContext, "A problem has ocured: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
There is something in Spanish, this is an old implementation that I had in a repo, I'm sure it will help you.
As you can see there, userLookup was a table of users with their current UID, so I can match that specific user id with the one in that table and get all user information.