Firebase,删除用户时无法删除用户的记录

时间:2018-02-17 10:25:55

标签: android firebase firebase-realtime-database firebase-authentication

当我删除用户时,我无法删除他的记录。我知道将删除哪些位置,但是当成功删除用户时,值仍在数据库中。

.....
final String useruid=""+user.getUid();

//auth = FirebaseAuth.getInstance();
//user=auth.getCurrentUser();


 dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            if(checkBox.isChecked()){
                if (user != null) {

                    user.delete()
                            .addOnCompleteListener(new OnCompleteListener<Void>() {
                                @Override
                                public void onComplete(@NonNull Task<Void> task) {
                                    if (task.isSuccessful()) {
    FirebaseDatabase.getInstance().getReference().child("profileinfos").child(useruid).removeValue();
    FirebaseDatabase.getInstance().getReference().child("holograminfos").child(useruid).removeValue();


                                        Toast.makeText(Ayarlar.this, "Hesabınız başarılı bir şekilde silindi. ", Toast.LENGTH_SHORT).show();
                                       dialog.dismiss();
                                        startActivity(new Intent(Ayarlar.this, LoginActivity.class));
                                        finish();
                                    } else {
                                        Toast.makeText(Ayarlar.this, "Bir Hata Meydana Geldi.", Toast.LENGTH_SHORT).show();

                                    }
                                }});
                }
            }
            else
            {
                Toast.makeText(Ayarlar.this, "Onaylamak için lütfen kutucuğu seçiniz.", Toast.LENGTH_SHORT).show(); return;
            }
        }
    });

Thats my database.

没有例外。

1 个答案:

答案 0 :(得分:1)

您必须先从数据库中删除它,然后从经过身份验证的控制台中将其删除,请尝试以下操作:

FirebaseDatabase.getInstance().getReference().child("profileinfos").child(useruid).removeValue();
FirebaseDatabase.getInstance().getReference().child("holograminfos").child(useruid).removeValue();

    user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
                            @Override
                            public void onComplete(@NonNull Task<Void> task) {
                                if (task.isSuccessful()) {
     Toast.makeText(Ayarlar.this, "Hesabınız başarılı bir şekilde silindi. ", Toast.LENGTH_SHORT).show();
                                   dialog.dismiss();
                                    startActivity(new Intent(Ayarlar.this, LoginActivity.class));
                                    finish();
                                } else {
                                    Toast.makeText(Ayarlar.this, "Bir Hata Meydana Geldi.", Toast.LENGTH_SHORT).show();

                                }
                            }});
            }