Is there a option to see all the open cursors in some point of time in sqlite ? I know that there is some functions to do this on .Net (to see all the connections to database...)
But what can I do with sqlite ?
I don't think there's a way of getting this information directly. What you can do, though, is create your own subclass of Cursor which tracks the currently open Cursors in a static list.
For example (pseudo-code, not tested):
public class TrackingCursor extends SQLiteCursor {
private static List<Cursor> openCursors = new LinkedList<Cursor>();
public TrackingCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
String editTable, SQLiteQuery query) {
super(db, driver, editTable, query);
openCursors.add(this);
}
public void close() {
openCursors.remove(this);
}
public static List<Cursor> getOpenCursors() {
return openCursors;
}
}
You need to supply your own Factory to the DB, so that your TrackingCursors will be created instead of plain SQLiteCursors.
public class TrackingCursorFactory implements SQLiteDatabase.CursorFactory {
Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
return new TrackingCursor(db, masterQuery, editTable, query);
}
}
And finally tell the DB to use this factory by passing the factory as a parameter when you call openDatabase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With