jeudi 6 août 2015

I have found many similar questions about sqlite in android however all ending with solution like ";" at the end of sql statment and so on

I have a statement:

    final String MY_QUERY = "SELECT "
            + "course_activity.course_id, "
            + "course_activity.activity_id, "
            + "courses.name, "
            + "activities.name "
            + "FROM "
            + "course_activity "
            + "INNER JOIN activities ON course_activity.activity_id = activities._id "
            + "INNER JOIN courses ON course_activity.course_id = courses._id "
            + "WHERE course_activity.course_id =?";

    String courseID = String.valueOf(course_id);

    Cursor cursor = database.rawQuery(MY_QUERY, new String[] {courseID});

    cursor.moveToFirst();

    DatabaseUtils.dumpCursor(cursor);

When instead of "?" I put "0" into the String statement, database is returning me some records, when there is a question mark and in debugger I se that in courseID I have "0" I dont get any results. I'm not sure that cursor is picking it up. Is it smoethng that it is int or should i use other function than rawQuery? What do I do wrong?

Aucun commentaire:

Enregistrer un commentaire