algorithms
algorithms

Reputation: 1085

How to see resulting Query string that has been built with SQLiteDataBase.query()?

For Debugging purposes I'd like to log my resulting Query that I generate with something like this:

SQLiteDatabase db = helper.getReadableDatabase();
Cursor c = db.query(
    TABLE_NAME,
    null,
    selection,
    selectionArgs,
    null,
    null,
    null
);

Is there any way to get the generated Query String?

Upvotes: 0

Views: 74

Answers (1)

laalto
laalto

Reputation: 152817

Internally SQLiteDatabase uses SQLiteQueryBuilder. You can use its buildQueryString() to generate the query string and rawQuery(sql, selectionArgs) to ensure the very same query is executed.

Upvotes: 1

Related Questions