Firebase查询方法不起作用 [英] Firebase query methods do not work
问题描述
这是我的数据树:
"look-twopointo": {
"0" {
"comment": "Hi"
"Text1": "Hello"
"Text2": "Bonsoir"
"type": "Bonjour"
"version": "4.0.6"
}
}
由于某种原因,查询没有工作。
For some reason querying doesn't work.
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mDatabase = FirebaseDatabase.getInstance().getReference().child("0");// pay attention to the this path reference
// Read from the database
Query query = mDatabase.child("version")/*.orderByChild("Text1")*/.equalTo("4.0.6")/*.startAt("d")/*.endAt("Dude")*/;
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
//String value = dataSnapshot.getValue(String.class); //these three lines below are probably the problem
String value = (String) dataSnapshot.getValue();
System.out.println(value);
Text.setText(value);
}
以下是系统吐出的内容:
Here is what the system spits out:
D/ViewRootImpl: ViewPostImeInputStage processPointer 0
D/ViewRootImpl: ViewPostImeInputStage processPointer 1
I/DynamiteModule: Considering local module
com.google.android.gms.firebase_database:4 and remote module
com.google.android.gms.firebase_database:6
Selected remote version of
com.google.android.gms.firebase_database, version >= 6
D/ResourcesManager: For user 0 new overlays fetched Null
W/System: ClassLoader referenced unknown path:
/data/data/com.google.android.gms/app_chimera/m/0000005e/n/armeabi-v7a
ClassLoader referenced unknown path:
/data/data/com.google.android.gms/app_chimera/m/0000005e/n/armeabi
D/ResourcesManager: For user 0 new overlays fetched Null
I/System.out: null
我不知道是不是因为我正在使用手机和避风港牛逼下载并试图在模拟器。有什么我必须设置,以便我可以在我的手机上查询?
I don't know if it's because I'm using my phone and haven't downloaded and tried it on an emulator. Is there something I have to setup so that I can query on my phone?
这是可能导致此错误的错误
This is the error that is probably causing this
05-28 17:12:42.743 2449-3078/? E/NetlinkEvent: NetlinkEvent::FindParam(): Parameter 'LABEL' not found
NetlinkEvent::FindParam(): Parameter 'UID' not found
或者我是这个
W/System: ClassLoader referenced unknown path:
/data/data/com.google.android.gms/app_chimera/m/0000005e/n/armeabi-v7a
ClassLoader referenced unknown path:
/data/data/com.google.android.gms/app_chimera/m/0000005e/n/armeabi
我希望它输出4.0。 6。
I want it to output 4.0.6.
更新:我实际上找不到错误。它为NO REASON输出null
Update: I actually couldn't find an error. It outputs null for NO REASON
推荐答案
要解决此问题,您需要将查询更改为:
To solve this, you need to change your query to:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
Query query = rootRef.orderByChild("version").equalTo("4.0.6");
并将返回所有版本$ c $的记录c>属性等于
4.0.6
。
And will return all the records that have the version
property equal with 4.0.6
.
这篇关于Firebase查询方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!