Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:19:25+00:00 2026-06-03T02:19:25+00:00

I get a android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that

  • 0

I get a android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here when starting a new Activity using OrmLite.

I’m not using any Cursors myself, so it must be the low level code that ORMLite uses. Not sure what the relevant code would be here, but basically I’m using Query/DeleteBuilders with 2 Dao objects usually inside a transaction manager. Minimal example that leads to the problem (exception handling removed):

return new TransactionManager(connectionSource).callInTransaction(new Callable<List<ConversionData>>() {
    public List<ConversionData> call() throws Exception {
        QueryBuilder<ConversionData, Date> builder = getDataDao().queryBuilder();
        builder.orderBy("date", /* desc */ true);
        return builder.query();
    }
});

Since neither the Dao nor the Builders have any close methods I’m not sure where exactly I should actually close.

There’s a close method in my Activity that extends OrmLiteBaseActivity, but then how would I open it again when I return from the other activity?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:19:28+00:00Added an answer on June 3, 2026 at 2:19 am

    So after some back and forth, this turned out to be a problem with a data iterator on a lazy collection that was not being closed. @Voo was doing something like the following:

    for (ConversionRate rate : conversionRates) { 
        if (rate.getCurrency().equals(curr)) 
            // you can't do this because otherwise the iterator won't be closed
            return rate; 
    }
    

    This problem happens once and a while. The documentation for iterators is explicit about it. To quote:

    NOTE: you must page through all items for the iterator to close the underlying SQL object. If you don’t go all of the way, the garbage collector will close the SQL statement some time later which is considered bad form. See the wrapped iterable below.

    The issue with lazy collections is also documented:

    WARNING: Most likely for(;;) loops should not be used here since we need to be careful about closing the iterator.

    To debug this problem, we first turned the lazy loaded collection into an eager one with @ForeignCollection(eager = true). That removed the problem indicating that it probably was a improper break out of a for loop or some other bad pattern.

    Good lesson for others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the below error message in android. Finalizing a Cursor that has not
I get frequently SQLiteDoneException, 06-29 02:03:34.816: WARN/System.err(30470): android.database.sqlite.SQLiteDoneException: not an error 06-29 02:03:34.816: WARN/System.err(30470):
I get this error android.database.sqlite.SQLiteException: near %: syntax error: , while compiling: SELECT _id,
When I start up my app, I get 02-05 18:50:14.943: ERROR/AndroidRuntime(328): Caused by: android.database.sqlite.SQLiteException:
I've been trying to get foreign keys working within my Android SQLite database. I
I am (re)writing an android app that uses an SQLite database to store various
I've created a custom view in an SQLite database for an Android application. I'm
package com.commonsware.cwac.wakeful.demo; import android.app.ListActivity; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.provider.BaseColumns; import android.util.Log;
When I wanted to get Android source code, I knew that I have to
as someone's who's just starting to get into Android/Java programming, I've read the docs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.