简体   繁体   中英

Android user registration in firebase using authnetication and it should display that data in realtime database

1 You have to design 2 screens. a) Registration screen b) Dashboard screen 2) Registration screen should contain below fields: a) First Name b) Last Name c) Email d) Mobile Number e) Password f) Confirm Password

  1. Registration Form should have standard validation like:

a) User can enter max 50 characters for First Name b) User can enter max 100 characters for Last Name c) Email standard validation (xx@xx.xx) d) Password should be in hidden e) Users can enter max 20 characters for Passwords. 4) Registration screen records should be inserted into the Firebase Realtime Database. 5) After submitting a record on the Registration screen, the user should redirect to the Dashboard screen. 6) On Dashboard Screen, Get all the users data from database and display list of users.

I have done the authentication is working fine but not showing in realtime database.

Are you add this data to real-time Database if not then first add that data using model like UserModel(). Than use that code to insert it into realtime database

DatabaseReference  mDatabase = FirebaseDatabase.getInstance().getReference();

Here is user model

public class User {

public String username;
public String email;

public User() {
    
}

public User(String username, String email) {
    this.username = username;
    this.email = email;
}

}

Than use this code to insert it into real time db

mDatabase.child("users").child(userId).setValue(user);

Go to firebase real-time db and check is you data inserted. if inserted than use that code to read data

mDatabase.child("users").child(userId).get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
@Override
public void onComplete(@NonNull Task<DataSnapshot> task) {
    if (!task.isSuccessful()) {
        Log.e("firebase", "Error getting data", task.getException());
    }
    else {
        Log.d("firebase", String.valueOf(task.getResult().getValue()));
    }
}

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM