I am building an Android App where I am using different ways for the user to register himself, like Email/Password, Phone, Google, Facebook, Twitter. I also
I presume you are using firebase for your authentication, since you tagged firebase in your question. Firebase authentication usually fetches the user's name during authentication so you can get those details during sign up, add them to your database and assign a unique id to each user. You can then create a friends node for each user on the system where their friends' ids will be stored. An example of sign up /sign in is shown below:
FirebaseAuth mAuth = FirebaseAuth.getInstance();
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
// Sign in success, get available information
final FirebaseUser user = mAuth.getCurrentUser();
if (user != null) {
if (user.getEmail() != null) {
//since various methods are available, you may want to use names
String name = user.getDisplayName();
//if email exists, you can try this
user.getEmail();
//otherwise, this is sure to exist but you may want to tell your users
//to complete their profiles later
user.getUid()
}
} else {
//Notify user
}
} else {
//The whole process failed
}
}
});