简体   繁体   English

如何从实时数据库和 Firebase 身份验证中删除用户? Android Java

[英]How to delete user from Realtime Database and Firebase Authentication? Android Java

Good day, do you guys know how to delete a data from realtime database at the same time with firebase auth account?美好的一天,你们知道如何使用 firebase 身份验证帐户同时从实时数据库中删除数据吗? This code is already working already deleting the data from the Realtime Database only, is there any way on how to delete it alongside with Firebase Authentication account?此代码已经在工作,已经仅从实时数据库中删除数据,有什么方法可以将其与 Firebase 身份验证帐户一起删除? Basicall my UUID from Firebase Auth and my Child from Realtime DB is the same as well.基本上我的来自 Firebase Auth 的 UUID 和来自 Realtime DB 的孩子也是一样的。

holder.btndel_stud.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("Users");
                final DatabaseReference firebaseUser = FirebaseDatabase.getInstance().getReference(FirebaseAuth.getInstance().getUid());
                final String uniqueKey = addingStudentsArrayList.get(position).getUniqueid();
                final String studentName = addingStudentsArrayList.get(position).getFullName();
                databaseReference.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(@NonNull DataSnapshot snapshot) {
                        databaseReference.child(uniqueKey).removeValue().addOnSuccessListener(new OnSuccessListener<Void>() {
                            @Override
                            public void onSuccess(Void aVoid) {
                                Toast.makeText(context, "Deleted User From Database...", Toast.LENGTH_SHORT).show();
                                firebaseUser.removeValue();
                            }
                        });
                    }
                    @Override
                    public void onCancelled(@NonNull DatabaseError error) {

                    }
                });

            }
        });

for reference here's the image of the account in Firebase Authentication供参考,这里是 Firebase 身份验证中的帐户图像在此处输入图像描述

and here's the image of the user's data stored in realtime database.这是存储在实时数据库中的用户数据的图像。 在此处输入图像描述

It's not possible to do both operations at the exact same moment in time.不可能同时进行这两项操作。 Realtime Datbase and Firebase Auth are different products with different APIs, and you will have to use their APIs separately to get this job done.实时数据库和 Firebase Auth 是具有不同 API 的不同产品,您必须单独使用它们的 API 才能完成这项工作。

If you want the user to be able to delete their data along with their account, you should write code to first delete the data from the database, then delete the account.如果您希望用户能够连同他们的帐户一起删除他们的数据,您应该编写代码先从数据库中删除数据,然后再删除帐户。

If you're trying to the data and the account for another user other than the one who is currently signed in, you will need to do all this work on a backend using the Firebase Admin SDK .如果您尝试使用当前登录用户以外的其他用户的数据和帐户,则需要使用Firebase Admin SDK在后端完成所有这些工作。 And again, you will need to deal with each product's APIs separately.同样,您需要分别处理每个产品的 API。

暂无
暂无

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

相关问题 如何通过android中的键从Firebase实时数据库中删除值? - How to Delete value from Firebase realtime database by key in android? 如何从firebase实时数据库中删除, - How to delete from firebase realtime database, 如何从firebase实时数据库中删除? - How to delete from firebase realtime database? 当用户关闭应用程序时,从Firebase Realtime数据库中删除数据 - Delete data from Firebase Realtime Database when user closes app 如何使用户能够从 Firebase 实时数据库中仅删除特定数据 - How to enable user to delete only specific data from Firebase Realtime Database 当用户单击卡片视图时,如何从Firebase实时数据库中删除显示在卡片视图上的特定记录。 - How to delete a specific record displayed on a cardview from Firebase Realtime Database when user clicks on a cardview. 如何在 Android 中取消 Firebase 实时数据库正在进行的写入或删除操作 - How to cancel Firebase Realtime Database ongoing write or delete operation in Android Firebase 实时数据库删除特定用户 - Firebase Realtime Database delete specific user 如何在Android应用程序的Firebase中从实时数据库中删除数据(json的特定节点) - How to delete data(particular node of json) from realtime database in Firebase in android app Java, Android studio, Firebase 数据库如何将数据添加到实时数据库 - Java, Android studio, Firebase database how to add data to realtime database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM