Logging SQL queries in android
adb shell setprop log.tag.SQLiteStatements VERBOSE
Don't forget to restart your app after setting this property.
It is also possible to enable logging of execution time. More details are availabe here: http://androidxref.com/4.2.2_r1/xref/frameworks/base/core/java/android/database/sqlite/SQLiteDebug.java
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.