Logging SQL queries in android

后端 未结 9 2315
野趣味
野趣味 2020-12-04 17:45

I am using the query functions in order to build the SQL queries for my tables. Is there a way to see the actual query that is run? For instance log it somewher

9条回答
  •  没有蜡笔的小新
    2020-12-04 18:07

    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.

提交回复
热议问题