Android访问带有钥匙的Firebase,其中包含空格 [英] Android access Firebase with Keys with spaces in them
问题描述
First Name
的firebase数据库中有一个键,然后我打电话给 FirstNameClass firstName = dataSnapshot.getValue(FirstNameClass.class);
FireNameClass {
Private String FirstName;
FirstName(){
}
FirstName(String firstName){
this.FirstName = firstName;
$ b $ p $它会返回null,因为它试图映射到名字,而不是与空间的名字。有没有不同的方式来实现这一点,因为我所有的价值观都有空间在他们的设计,我愿意做额外的工作,以保持这种设计,如果可能的话。解决方案尝试使用 @PropertyName
。你的模型应该是这样的:
$ $ $ $ $ $ $ $
$ b $ Property $ Name
public String FirstName;
...
}
我没有尝试过。如果它不工作,我想我知道另一种方法来做到这一点,并将更新这个答案。
希望这有助于
This might be a dumb question but I couldn't find any examples on google's firebase site. If I have a key in the firebase database of "First Name"
and then I call
FirstNameClass firstName = dataSnapshot.getValue(FirstNameClass.class);
FireNameClass{
Private String FirstName;
FirstName(){
}
FirstName(String firstName){
this.FirstName = firstName;
}
}
It'll return null because it's trying to map to FirstName instead of First Name with a space. Is there a different way to achieve this because all my values have spaces in them just by design and I am willing to do extra work to keep this design if possible.
Try using @PropertyName
. Your model should look like this:
FireNameClass{
@PropertyName("First Name")
public String FirstName;
...
}
Note: I haven't tried it. If it doesn't work, I think I know another way to do it and will update this answer
Hope this helps
这篇关于Android访问带有钥匙的Firebase,其中包含空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!