1
votes

I have created an admin panel and I have registered the users. Now I want to connect those users to database so that i will send data to those users which be accessed by users later...

Can I send data to users database by using their email address? Please this is my main logic.

  public void onClick(View view) {
                email=userEmail.getText().toString();
                password=UserPassword.getText().toString();
                mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(AddUsers.this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()){
                            Toast.makeText(AddUsers.this, "User is Added", Toast.LENGTH_SHORT).show();

                        }
                    }
                });
            }
        });
    }

Ok i will explain it .....i want an admin application from which i will send tasks or data to users that are registered on firebase... e.g [email protected] is a user. and user have his own application which will show the data that admin sends..Now from admin app i want to send data to above email user...so when the user open the application the data is rereived to his app.. enter image description here Here is admin front end image

1
What do you mean with send data to users database? You want to send emails to your users? - Alex Mamo
If you mean find users by their emails, you will need to write the mapping from user ID to user email to Firebase Database. Then you will be able to retrieve them because you will have each user's ID. - Minas Mina
Alex Mamo those users who are registered through their email and passwords...i want each user to be linked with his data... - muhammad obaid

1 Answers

1
votes

Yes, you can save data in user database node..us there userId for node creation and you can compare user data in your database node as well.!

public void onClick(View view) {
    email=userEmail.getText().toString();
    password=UserPassword.getText().toString();
    mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(AddUsers.this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()){
                AddUserInfo(task.getResult().getUser().getUid());
                Toast.makeText(AddUsers.this, "User is Added", Toast.LENGTH_SHORT).show();
            }
        });
    });
}

private void AddUserInfo(String id) {
    UserClass user=new UserClass();
    user.setUserID(id);
    user.setUserName(Name);
    user.setUserPassword(Password);
    mdatabaseReference.child("Users").child(id).setValue(user);
}