1

I have the doubt to wether sqlbrite close cursor automatically, it seems that it doesn't do it since I keep getting :

java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:809) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793)

but I don't see anything in docs stating that I should be explicitly call cursor.close.

Edit 1

Here is a snippet of what is giving me a cursor not close error:

DbProvider.db(getActivity()).createQuery(Item.NAME, sqlQuery, selectionArgs).mapToList(new Func1<Cursor, ItemEntity>() {
    @Override
    public ItemEntity call(Cursor cursor) {
        return new ItemEntity(cursor);
    }
}).subscribe(itemEntities -> {
    Debug.info(this, "items " + itemEntities );
}, Throwable::printStackTrace, () -> {});
Necronet
  • 6,704
  • 9
  • 49
  • 89

1 Answers1

1

if you are calling query.run() and getting a cursor you need to close it manually. If you are using the mapToList/mapToOne api's you do not need to close it manually.

Anstrong
  • 734
  • 3
  • 7
  • The issue was that I was using loader API before calling `db.createQuery` because I am migrating the code to sqlbrite, so it seem there was a raise condition there that threw an error. – Necronet Apr 21 '17 at 15:25
  • Official answer from a github issue in sqlitebrite: https://github.com/square/sqlbrite/issues/94 – Necronet Apr 21 '17 at 16:37