I don't know how to reload a user-generated object when it is stored in the Firebase database.

Asked 2 years ago, Updated 2 years ago, 75 views

First, give the child twice as profile and tmp I added an object I created called Profile to the database, and it was underneath that weird text The email or nickname cannot be retrieved when needed. (Because I can't put in that weird text)

I'd appreciate it if you could tell me what to do.

First, the Profile object that I created is as follows

package com.mtjin.studytogether.realtime_database;

public class Profile {
    private String email;
    private String nickName;
    private String sex;

    public Profile(String email, String nickName, String sex) {
        this.email = email;
        this.nickName = nickName;
        this.sex = sex;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return email;
    }


}

And when you put a value in the database,

profile = new Profile (mEmail, mNickName, mSex);
mProfieDatabaseReference.child("TMP").push().setValue(profile);

I put it in like this. mProfiDatabaseReference is child and has root and profile. TMP is a child that I put in temporarily.

If I insert an object like this, will the original database contain strange characters? And I'd appreciate it if you could tell me how to get that out.

Currently, I can't match the key value of that strange character, so I can't read the profile information...

I need to be able to retrieve my DB's profile information at any time.

firebase database

2022-09-22 19:25

1 Answers

I solved it. The push() automatically generates an ID, so that's why such a strange ID is formed.


2022-09-22 19:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.