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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:24:13+00:00 2026-05-23T05:24:13+00:00

I am writing an android application that is trying to pull data from a

  • 0

I am writing an android application that is trying to pull data from a database based on two separate criteria.

The fields of workout and exercise are both strings in the database. I want to return a cursor with only those rows that satisfy BOTH criteria. Oh and I would also like it to be sorted in date order…

public Cursor graphQuery(String exercise, String workout) {
     Cursor cursor = mDb.query(DATABASE_TABLE, new String [] {KEY_DATE, KEY_REPS,       
         KEY_REPS_FEEL, KEY_WEIGHT, KEY_WEIGHT_FEEL}, "KEY_WORKOUT=" + workout + "AND" +  
         "KEY_EXERCISE=" + exercise, null , null, null, KEY_DATE); 

     return cursor;
}

I am a new android coder and would appreciate the help!

  • 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-05-23T05:24:14+00:00Added an answer on May 23, 2026 at 5:24 am

    Use selection and selectionArgs:

    public Cursor graphQuery(String exercise, String workout) {
         Cursor cursor = mDb.query(DATABASE_TABLE, new String [] {KEY_DATE, KEY_REPS,       
             KEY_REPS_FEEL, KEY_WEIGHT, KEY_WEIGHT_FEEL}, "KEY_WORKOUT = ? AND KEY_EXERCISE = ?",
             new String[] { workout, exercise },
             null,
             null,
             KEY_DATE); 
    
         return cursor;
    }
    

    Notice how the selection String has ?s inplace of actual values and the actual values are passed in as a String[] and in the selectionArgs paramter. SQLite will replace those ?s with the values from the String[] selectionArgs.

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

Sidebar

Related Questions

I'm writing an android application that maintains a lot of state data...some of it
I'm writing an application that will ship in two versions: Android and PC version.
Im writing an Android application that needs to access data stored in a mongodb
I am writing an HTML5 application that is gathering data from a few different
I'm writing code for an Android application that is supposed to take data, package
I am trying to writing code so that my android application can query a
In short, I am writing an Android application that I want to have pull
I'm writing an Android application that I want to be able to send requests
I'm writing an android application that draws directly to the canvas on the onDraw
I'm writing an Android application for RC Cars. It uses a SQLite database, and

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.