Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9190951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:34:19+00:00 2026-06-17T20:34:19+00:00

Using the code below i can check if a row contains a single string

  • 0

Using the code below i can check if a row contains a single string ( String a) but how would i check if a row equals either string (String a or b)?

public Cursor fetchMyList() {
        String[] columns = { KEY_ROWID, KEY_CATEGORY, KEY_SUMMARY,
                KEY_DESCRIPTION, KEY_EMAIL };
        String selection = "description=?";
        String a = "blue";
                String b = "red";

        String[] selectionArgs = { a };
               // String[] selectionArgs = { a , b}; ///tried this dont work!!
        Cursor cursor = null;
        try {
            cursor = database.query(DATABASE_TABLE, columns, selection,
                    selectionArgs, null, null, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        int numberOfRows = cursor.getCount();
        if (numberOfRows <= 0) {
            return cursor;
        }
        return cursor;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:34:21+00:00Added an answer on June 17, 2026 at 8:34 pm

    You can only pass 2 arguments if you declare 2 arguments. This is what you want:

    String selection = "description=? OR description=?"; // Select rows with either description
    String[] selectionArgs = {a , b};
    

    I strongly suggest you check SQL language.

    PS: do not catch Exception. You’ll regret it later. Catch specifc Exception children; in your case you want to catch SQLException.

    PS2: use Log instead of printStackTrace().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the code below I can insert a new row to my table (
I can insert a row by using code below. USE pmdb; INSERT INTO md5_tbl
In past, I am using Listview and using below code can show a particular
I am using the code below, its basically babylonian method, how can i modify
I am using below code to generate photo gallery from a folder. How can
I'm using the code provided below to display time and date. can anyone help
i can establish a connection using HttpUrlConnection. my code below. client = new DefaultHttpClient();
Using the code below I can trap an invalid cell entry. In this simple
how can i check if a textfield contains a specific value i tried using
I am using the code below but it is giving time out error. Though

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.