How to search data in Firebase?

后端 未结 2 2051
感情败类
感情败类 2021-01-23 18:20
Bundle bundle = getIntent().getExtras();
   String name = bundle.getString(\"name\");

   mValueView = (TextView) findViewById(R.id.textView);

   mRef = FirebaseDatabas         


        
2条回答
  •  半阙折子戏
    2021-01-23 18:52

    If you want to search title value only one time, without listening for updates, you can simply use :

    ref.addListenerForSingleValueEvent(
                        new ValueEventListener() {
                            @Override
                            public void onDataChange(DataSnapshot dataSnapshot) {
        }});
    

    Then if you get a reference to 'Users' you can do some logic with iteration, for example :

    for (DataSnapshot singleSnapshot : dataSnapshot.getChildren()){
        String title = (String) singleSnapshot.child("title").getValue();
                            //do your logic
                        }
    

提交回复
热议问题