简体   繁体   English

Firebase用户未从Android的ListView中删除

[英]Firebase User not deleting from ListView of Android

As per Title i want to clear some flow of my app. 根据标题,我想清除我的应用程序的流程。 First Employee gets Login to application and will view list of customers in ListView of Android. 第一员工登录到应用程序,并将在Android的ListView中查看客户列表。 I want that when employee wish to delete any customer they can by selecting any customer for any reason. 我希望当员工希望删除任何客户时,可以出于任何原因选择任何客户。

I did code on delete button as shown below: 我在删除按钮上做了代码,如下所示:

Found from StackOverflow itself 从StackOverflow本身找到

 FirebaseUser  user = FirebaseAuth.getInstance().getCurrentUser();
             user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if(task.isSuccessful())
                {
                   // FirebaseAuth.getInstance().signOut();
                    Snackbar.make(coordinatorLayout, "Customer Deleted", Snackbar.LENGTH_LONG).show();

                }
                else
                {
                    Snackbar.make(coordinatorLayout, "Customer Not Deleted", Snackbar.LENGTH_LONG).show();
                }
            }
        });

Now the issue is when this code runs.... it delete the employee which is logged in and not that user/customer to whom he wish to delete. 现在的问题是该代码何时运行...。它删除了登录的员工,而不是他希望删除的用户/客户。

Please guide me what changes i should make to fulfill my task. 请指导我为完成我的任务应该进行哪些更改。

FirebaseAuth.getInstance().getCurrentUser();

Get's the current user and that's what it deletes,what you should do instead is: Get是当前用户,它就是要删除的用户,您应该做的是:

String uid=...//of which user you want to
Firebase users = myFirebaseRef.child("users");
users.equalTo(uid);

Then call the delete method 然后调用delete方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM