mardi 6 octobre 2015

query with dynamic selectionArgs android SQLite

I am trying to return a cursor with all the rows which match one of the id's in the String Array ids - This is what I have so far I am getting the error below. I am thinking it has something to do with the fact it has only 1 '?' but how do I then make this dynamic? Any suggestions?

public Cursor getSelectedEntries(String... ids)
{

    return movieDbInstance.query(
            DATABASE_TABLE,
            new String[]{_ID, MOVIE_ID, MOVIE_TITLE, MOVIE_YEAR, MOVIE_POSTER},
                MOVIE_ID + " = ?",
            ids,
            null,
            null,
            null);
}

The String array has a changing number of ids for example it could be {"abc","def"} or it could be {"abc","def","gef","gdf"} and I need to return all rows where the MOVIE_ID = one of them...

Error Message`java.lang.IllegalArgumentException: Cannot bind argument at index 10 because the index is out of range.

The statement has 1 parameters. at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:212)`

Aucun commentaire:

Enregistrer un commentaire