Firebase Query to search data with value of a key

The example in this post uses Firebase Query to search for a specific username, entered by user in an EditText, in a list of all users.

1. The data to be searched is shown in image below. We will search the value of key "username".

2. In View area of your project, add an EditText edittext1, a Button button1, and a ListView listview1.

3. Create a Custom View user.xml. In this page, add an ImageView imageview1 and a TextView textview1 to display the details retrieved.

The ImageView here has width and height 40 and scale type CENTER_CROP. The linear containing them has Gravity center_vertical.

4. For listview1 select user.xml as CustomView.

5. Create a FirebaseDb component (user) specifying the data location (users) to be searched.

6. Add a String variable query, and a List Map result_users.

7. In onCreate event use FirebaseDb stop listening.

8. In button1 onClick, set String query to text in  edittext1. Then use code to search for query in the FirebaseDb component.
The code used is

Here user is FirebaseDb component, username is the key whose value is searched, valuelistener2 is a ValueEventListener which gets a snapshot of the result of this query.

Note: This code gets the values of username which are exactly equal to the characters entered in edittext1, and it is case sensitive. And changes in case of letters or any extra or missing spaces do not lead to the desired result.

9. Create a More Block extra. Here put } in beginning and { in end. Use codes and blocks as shown in image below.
i. Define valuelistener2 with onDataChange method.
ValueEventListener valuelistener2 = new ValueEventListener() {
public void onDataChange(DataSnapshot _param1) {

ii. Clear List result_users.

iii. In onDataChange method, for each child (_data) of DataSnapshot (_param1), get the value in the form of a Map variable (_map) and add it to list result_users.
GenericTypeIndicator <HashMap<String, Object>> _ind = new GenericTypeIndicator<HashMap< String, Object>>() {};
try {
for (DataSnapshot _data : _param1.getChildren()) {
HashMap <String, Object> _map= _data.getValue(_ind);

iv. Display result_users in listview1.

v. Close try{ with } and catch Exception. Then close onDataChange method and add onCancelled method. Nothing to do in onCancelled method.
} catch (Exception e) {
showMessage(e.toString()); }

public void onCancelled(DatabaseError databaseError) { }

10. In onBindCustomView, use blocks to display the values of keys in the List result_users. See image below.

The url used to display a default profile pic if no pic is uploaded by user:

11. Save and run the project.


  1. Really Great!
    Please, what codes are required to enable a sound/voice record option in a website in sketchware app? Like, if the site has a voice note option, it works on browsers but the function not working in webview.

    e.g. The website has a sound/voice record option but this does not work when webview is embedded in sketchware app. Please help out

    1. Watch Out The Tutorials of
      ''Aaura Parti''
      He Told Everything in Detail

  2. I need a help plz. Is there any way to execute lua or cpp on app? I have the lua source & I want to use it on sketchware. How can I do this?

  3. Brother how to create firebase app store in sketchware

  4. Earn $500 Per Month Easily

    Join Telegram Group

    Hi, I have an amazing website where you can earn easily for a lifetime.
    Payment Methods
    Perfect Money
    Bucksmil (Easypaisa, Jazz Cash, Bank)
    Cashmaal (Easypaisa, Jazz Cash, Bank)
    Earn daily up to USD 5 for a lifetime with and spill PTC system. 50% direct referral commission and 10 % auto referrals commission.
    You can earn also and spill the auto spillover system. 1000% real website working since 1 year.
    No fraud no scam.
    Instant withdrawal and deposit system.
    For more details visit
    For more details visit

  5. Ascending key value and Descending key value please 🥺

  6. Hello, how to count number of data using specific value, inexample, count number of children in a specific class using data on firebase?


Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Firebase auth in Sketchware for Login Activity

Simple car racing android game in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Create a PDF reader android App in Sketchware