0

I'm trying to add a WHERE clause or a filtering feature in the onCreateLoader to populate values in a ListView. I think my syntax is correct, but every time the app loads to that activity, it crashes.

Here is my code:

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String courseQry = DBOpenHelper.COURSE_TERM + "=?";
    String[] courseArg = {"Term 1"};
    return new CursorLoader(this, CourseProvider.COURSE_CONTENT_URI,
         null,courseQry, courseArg, null);
}

When i tried adding a question mark after the equal sign, I am able to load the activity, but nothing is being shown in the ListView.

I'm not really sure what to do?

afrocode
  • 17
  • 1
  • 2
  • 9
  • Post the stacktrace so we can help you. – rubenlop88 Nov 07 '16 at 02:32
  • I figured it out. Your right about looking at the stacktrace! The problem with using the code was it gives me this: WHERE courseTerm=Term 2 I just need to put the string value (Term 2) in quotes, so i changed the syntax to this: String courseQry = DBOpenHelper.COURSE_TERM + "=" + '"' + thisTermNum + '"'; and it worked! – afrocode Nov 07 '16 at 03:03

0 Answers0