How to save google and Facebook login integration into firebase Realtime database Android Studio Java

I know how to save basic (email and password) information into my Firebase database but I have no idea how to save google and Facebook login integration into my Firebase database Can someone explain me?

Code of Google Login Integration

 private void firebaseAuthWithGoogle (GoogleSignInAccount acct){

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
            .addOnCompleteListener(this, new OnCompleteListener() {
                public void onComplete(@NonNull Task task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        FirebaseUser user = fAuth.getCurrentUser();
                        Intent intent = new Intent(getApplicationContext(), MainActivity.class);

                    } else {
                        Toast.makeText(login.this, "Sorry auth failed.", Toast.LENGTH_SHORT).show();


                    // ...


For Facebook in registerCallback, you will get the user name,email and unique id by which you can check which user is this. Here is the example code:

            new FacebookCallback<LoginResult>() {
                public void onSuccess(LoginResult loginResult) {
                    GraphRequest request = GraphRequest.newMeRequest(
                            (object, response) -> {
                                try {
                                 String id = object.getString("id");
                               String  name = object.getString("name");
                                String  email = object.getString("email");
                                } catch (JSONException e) {
                                    Log.e("login", e.getMessage());

                                } else
                                    Toast.makeText(getApplicationContext(), "Fail to connect with Facebook, Try again later!", Toast.LENGTH_LONG).show();

                    Bundle parameters = new Bundle();
                            "id,name,email,gender, birthday");


                public void onCancel() {


                public void onError(FacebookException error) {

And for Google in handleSignInResult, same you will personName, personEmail and personId by which you can check which user is this. Here is the example code:

 private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
        try {
            GoogleSignInAccount account = completedTask.getResult(ApiException.class);
            if (account != null) {
                String personName = account.getDisplayName();
                String personEmail = account.getEmail();
                String personId = account.getId();
        } catch (ApiException e) {

Note: Still if you don’t understand something let me know.