SQL Android Query formulation with multiple conditions

Viewed 17893

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!

2 Answers
Related