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 9122801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:11:18+00:00 2026-06-17T06:11:18+00:00

I have a database in my app with several columns of which 3 are:

  • 0

I have a database in my app with several columns of which 3 are: _id name selected.
Now, I want to read a single selected value from a row with the name being a string I get from some code. What would be the best way to do this?
Thanks

P.S. I am getting that value to check if it’s 0 or 1 (only two possible values), so I want to ask how to make a kind of an if statement in the return field? I have seen some people do it with something resembling this: return true ? ... false

EDIT:
Okay, this is my code atm, haven’t checked it yet since I need to do some other things to get it all up, but I think there may be a better way to do this.

public boolean isBandSelected(String name) {
    // TODO Auto-generated method stub
    Cursor cursor = mDb.query("bands", new String[] { "selected" }, "name="
            + name, null, null, null, null);
    int index = cursor.getColumnIndex("selected");
    String selected = cursor.getString(index);
    return selected == "1";
}
  • 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-17T06:11:19+00:00Added an answer on June 17, 2026 at 6:11 am

    You can use regular expression to match rows whose name field being string. Many databases can support regular expression.

    The ternary operator(? 🙂 can be used to make return statement like this.

    return value == 0 ? false : true
    

    But it depends on what kind of data type you what to return. Code above returns boolean data type.

    The last line of your code above will always return false. This is because the == operator compares the reference of the two objects. you can use:

    return "1".equals(selected); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have csv files, java app and database, i read csv file from my
I have an App which receives a SQLite database to read some data and
I have implemented an App which uses SQLite database, now if I run the
I have a app that searches a database and retrieves 3 fields Name, Email
An iPhone app which I am creating generates reports from a Core Data database
The application I am working on have several database fields called active, which is
I have an app in the app store which a database in the resources
I have a mysql database table called character with columns like name, strength, intelligence,
I have a project called MyApp.DataAccess which contains several database contexts. This started as
I have several installations of my Linq-to-Sql app running in the field. Now I've

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.