The code that causes the StringIndexOutOfBoundsException
is the following.
/* package */ SQLiteProgram(SQLiteDatabase db, String sql) {
mDatabase = db;
mSql = sql.trim();
db.acquireReference();
db.addSQLiteClosable(this);
this.nHandle = db.mNativeHandle;
// only cache CRUD statements
String prefixSql = mSql.substring(0, 6); // <<<< HERE
The only reason why you can get that exception is a String
with less than 6 characters. (Your's is length=0;
i.e. empty after the trim()
a few lines above)
There is no indication where or how exactly you manage to put an empty string in there. It comes from a SQLiteDatabase.rawQuery
but that could have been called from other query methods. Look further down the stacktrace and look through your code where you are possibly passing an empty string to a query method.
Your query also seems to break the syntax of the where clause:
If there is an AND
it would have to be
WHERE {condition} AND {another condition expected here} GROUP BY ...
You have either forgot to add another expression or you have an AND
too much.
And table
is a reserved keyword. To use those as names you'll have to quote them. SQLite supports quotation marks ("), backticks (`) and brackets ([]).