0

Here is my data tree:

"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

or it my be this

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

I want it to output 4.0.6.

Update: I actually couldn't find an error. It outputs null for NO REASON

Jose Salgado
  • 29
  • 1
  • 6

1 Answers1

3

To solve this, you need to change your query to:

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
Query query = rootRef.orderByChild("version").equalTo("4.0.6");

And will return all the records that have the version property equal with 4.0.6.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • Im having error that pops out like this when I enter your code `E/AndroidRuntime: FATAL EXCEPTION: TubeSockReader-1 Process: com.look.leopoldo.look, PID: 24911 java.lang.OutOfMemoryError: Failed to allocate a 21856 byte allocation with 4832 free bytes and 4KB until OOM at java.nio.CharBuffer.put(CharBuffer.java:501)` – Jose Salgado May 27 '18 at 18:11
  • This seems to be another problem. You can take a look here [here](https://stackoverflow.com/questions/32244851/androidjava-lang-outofmemoryerror-failed-to-allocate-a-23970828-byte-allocatio/45677413). Do you think that my answer helped you for the initial issue? – Alex Mamo May 28 '18 at 03:31
  • I fixed the out of memory error but it turns out that was wasn't the issue.Turns out this is the issue '05-28 17:12:42.743 2449-3078/? E/NetlinkEvent: NetlinkEvent::FindParam(): Parameter 'LABEL' not found NetlinkEvent::FindParam(): Parameter 'UID' not found' – Jose Salgado May 29 '18 at 00:15
  • or it be because of this `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` – Jose Salgado May 29 '18 at 03:01
  • It turns out that you get another issues that are not related with the initial one. In order to follow the rules of this comunity, please post another fresh question, so me and other users can help you. – Alex Mamo May 29 '18 at 07:43
  • Your answer didn't help me. – Jose Salgado May 29 '18 at 20:50