I want to create a function where user can remove their own account. If the user removes their account. All their information will be deleted and user authentication also will be removed. I have created the function but somehow at the Firebase authentication the user email did not get deleted.
The picture above shows the account has been deleted but inside the authentication the account still not gets deleted.
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder dialog = new AlertDialog.Builder(CustProfileActivity.this);
dialog.setTitle("Are you sure?");
dialog.setMessage("Deleting this account will result in completely removing your " +
" account from the system and you won't be able to access the app.");
dialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
progBar.setVisibility(View.VISIBLE);
FirebaseDatabase.getInstance().getReference().child("Customer").child(firebaseAuth.getCurrentUser().getUid()).removeValue();
currentUser.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
progBar.setVisibility(View.GONE);
Toast.makeText(getApplicationContext(), "Account Deleted", Toast.LENGTH_SHORT).show();
Intent intent= new Intent(getApplicationContext(),LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
});
dialog.setNegativeButton("Dismiss", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog alertDialog = dialog.create();
alertDialog.show();
}
});
I want to achieve a result where user account will get deleted including their data inside the firebase authentication.