简体   繁体   中英

Unable To Insert Record FireBase

I just want to insert data on User table inside firebase for this I have created collection of tables, here is the screenshot

Collection

在此处输入图片说明

and using this to refer the location of table

 final DatabaseReference databaseReference = database.getReference("sharelocation-c7f0f/database/firestore/data~2FUsers~2Fz5hgLqzkdOKKctKpmyex");

and this is the code to save the user

Save User

    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
                                LocalDateTime now = LocalDateTime.now();
                                HashMap<String,String> user =new HashMap<>();
                                user.put("Name","fake");
                                user.put("Email","fake@test.coom");
                                user.put("Device",android.os.Build.MODEL);
                                user.put("Phone", String.valueOf( "32254523"));
                                user.put("RegisterOn",dtf.format(now));

                                user.put("isActive",String.valueOf("true"));

                                user.put("isLogin",String.valueOf("true"));

                                databaseReference.setValue(user);

                                Toast.makeText(RegisterActivity.this, "Successfully registered!", Toast.LENGTH_LONG).show();

please let me know if I am missing something as I am new at firebase.

Your screenshot is showing data in Cloud Firestore, but your code is using the SDK for Firebase Realtime Database. These databases are completely separate from each other. If you want to use Firestore, you should follow the documentation for working with it instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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