First of all, I have a page for user to register their account to firebase. They have to insert their name, ID, email, and password. Then the email will register in the Firebase Authentication and the name, ID, Email will save in the Firebase Database. Now, I try to delete the user data and delete the Authentication in the same time. Suppose I login as Admin and I want to delete the data as attach in the Image, how can i delete the selected user both database and authentication in the same time ?
**PS: The data is show in the List View and LongClick to select user to delete.
Here is my code.
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ActivityAdminPage.this);
alertDialog.setTitle("Are You Sure?");
alertDialog.setMessage("Delete the User and the User will not longer able to Login to the " +
"System anymore.");
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
DatabaseReference databaseR = FirebaseDatabase.getInstance().getReference("User");
databaseR.removeValue();
}//end of YES Button Click
});
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//do ntg
}
});
alertDialog.create();
alertDialog.show();
return true;
}//End of Long Click