Firebaseを使用するのが非常に新しいと言って始めましょう。私はプッシュを使用して、私のFirebaseデータベースに「mGameSessionID」と呼ばれる文字列()でカスタムオブジェクトをプッシュしようとしていますAndroid/Java Firebaseがキー/参照に予期しない値を追加する
:「.setValue(gameSession)」を使用して値を設定するときしかし、
DatabaseReference pushedPostRef =
myRef.child(myRef.push().getKey());
String gameSessionID = pushedPostRef.getKey();
GameSession gameSession = new GameSession(gameSessionID);
pushedPostRef.setValue(gameSession);
は、それが追加されますデータベースここ
に余分gameSessionID値はGameSessionクラスです:
String mGameSessionID;
GameSession()
{
}
GameSession(String gameSessionID)
{
mGameSessionID = gameSessionID;
}
public String getGameSessionID()
{
return mGameSessionID;
}
public void setGameSessionID(String gameSessionID)
{
mGameSessionID = gameSessionID;
}
ああ、わかりました、明確化のためにありがとうございます。時には私は私が何かを私的または公的に宣言していないことを忘れています! – Darkstorm51