I am using the
query
/**
* Implement the cursor factory in order to log the queries before returning
* the cursor
*
* @author Vincent @ MarvinLabs
*/
public class SQLiteCursorFactory implements CursorFactory {
private boolean debugQueries = false;
public SQLiteCursorFactory() {
this.debugQueries = false;
}
public SQLiteCursorFactory(boolean debugQueries) {
this.debugQueries = debugQueries;
}
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
if (debugQueries) {
Log.d("SQL", query.toString());
}
return new SQLiteCursor(db, masterQuery, editTable, query);
}
}
You can apply your own SQLiteDatabase.CursorFactory
to the database. (See the openDatabase parameters.) This will allow you to create your own subclass of Cursor
, which keeps the query in an easily accessible field.
edit: In fact, you may not even have to subclass Cursor
. Just have your factory's newCursor()
method return a standard SQLiteCursor
, but log the query before doing so.