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

  • Home
  • SEARCH
  • 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 6963111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:44:50+00:00 2026-05-27T15:44:50+00:00

I am using Cursor to get data from DB (it’s information about the overlay

  • 0

I am using Cursor to get data from DB (it’s information about the overlay markers on Map). I am loading a map with help of this data. Interaction with the DB through Cursor is done in a asyncTask.

Now here is the problem I am facing. If I press back button while the cursor is running to load the map (i.e. in middle of loading overlay markers in a while loop) I get this error:

Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery (mSql = SELECT _id, category, latitude, longitude FROM node) 

Here is the complete trace of it:

12-21 11:11:30.173: E/AndroidRuntime(2824): FATAL EXCEPTION: AsyncTask #5
12-21 11:11:30.173: E/AndroidRuntime(2824): java.lang.RuntimeException: An error occured while executing doInBackground()
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at  java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.lang.Thread.run(Thread.java:1102)
 12-21 11:11:30.173: E/AndroidRuntime(2824): Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery (mSql = SELECT _id, category, latitude, longitude FROM node) 
 12-21 11:11:30.173: E/AndroidRuntime(2824):    at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:34)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:64)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:299)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:271)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:188)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.database.AbstractCursor.moveToNext(AbstractCursor.java:256)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at org.mid.kew.activities.MapPageActivity$MapLoadingAsyncTask.doInBackground(MapPageActivity.java:632)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at org.mid.kew.activities.MapPageActivity$MapLoadingAsyncTask.doInBackground(MapPageActivity.java:1)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
12-21 11:11:30.173: E/AndroidRuntime(2824):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-21 11:11:30.173: E/AndroidRuntime(2824):     ... 4 more

and here is a snapshot of code I am using in asyncTask

Under DoInBackground method

openKewDataBase();
Cursor cursor = getCursorForOverLayIcons();
startManagingCursor(cursor);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
            ...

    cursor.moveToNext();
}

cursor.close();

Under onPostExecute Method

....

closeKewDataBase();

As per I can trace Its crashing at “cursor.moveToNext();”

  • 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-05-27T15:44:50+00:00Added an answer on May 27, 2026 at 3:44 pm

    As you are manually closing the cursor with cursor.close(), you shouldn’t call startManagingCursor(cursor). You need to choose one or the other.

    As you are doing this in an AsyncTask, you almost certainly don’t want the enclosing Activity to manage the cursor for you, as the AsyncTask can outlive the Activity. So just do it manually.

    (I presume the AsyncTask is an inner class of your Activity.)

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

Sidebar

Related Questions

I'm using a virtual lit control and I get the data from a map.
I'm using the following method to get data from a table: Cursor c =
I wan't to get data's from CallLog.Calls.CONTENT_URI in non Activity classes. Am using cursor
In my application I use cursor to get information from SQLite data base like
I am fetching data from cursor. Using this cursor i am populating the text
Is it possible to get ref cursor from oracle stored procedure by using DAAB
I'd like to use SQLiteCursor class to fetch data (not using Cursor class). This
I've fetched the records from Database using Cursor. It works perfectly, but, I get
In my app i am using this code to get Image from Gallery and
I want to know how we can get record count using reference cursor in

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.