【问题标题】:Data is not showing(not uploading) in firebase database in android studioandroid studio的firebase数据库中的数据未显示(未上传)
【发布时间】:2018-08-30 17:56:14
【问题描述】:

这是我的代码,我正在将学生姓名和批次名称上传到 firebase 数据库。该方法在用户创建账号成功后执行。 在 Authentication 中创建了用户,但数据没有上传到数据库,logcat 中唯一的错误是:

E/SpellCheckerSession:由于意外 mState=TASK_CLOSE scp.mWhat=TASK_CLOSE 而忽略 processOrEnqueueTask

private void uploadUserDetails(){
        String name = studentName.getText().toString();
        String batch = "BCA";
        database = FirebaseDatabase.getInstance();
        DatabaseReference ref = database.getReference(firebaseAuth.getUid());
        Student student = new Student(name,batch);
        ref.child("Student Details").setValue(student);
    }

public class Student {
    public String name;
    public String batch;

    Student(){
        this.name= "Hello";
        this.batch="Unspecified";
    }
    Student(String name,String batch){
        this.name=name;
        this.batch=batch;
    }
}

【问题讨论】:

  • 贴出学生班级也
  • 您确定该错误与实时数据库有关吗?我觉得它不熟悉。
  • 我不知道,Firebase 数据库上的数据没有更新,这是我在 logcat 中遇到的唯一错误
  • 你能把整个 logcat 包括进来吗?

标签: android firebase firebase-realtime-database


【解决方案1】:

下面的 sn-p 使用一个映射来存储学生姓名和他的批次,在这个映射中,键是字符串,值是对象类型。并输入键“l”的值。

    Map<String, Object> updates = new HashMap<>();
    updates.put("l", Arrays.asList(student.batch,student.name));
    ref.child("Student Details").setValue(updates);

【讨论】:

  • 我想我应该提到您应该使用您的贡献下方的edit 链接将其直接添加到答案中。评论可能会从网站上删除,因为它们只能用于澄清。这次我已经为你完成了:-)
猜你喜欢
  • 2020-08-27
  • 2019-11-11
  • 1970-01-01
  • 2018-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-06
  • 1970-01-01
相关资源
最近更新 更多