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 8734657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:53:13+00:00 2026-06-13T09:53:13+00:00

I have a big problem.. This is the code: private class ViewDataTableTask extends AsyncTask<Void,

  • 0

I have a big problem.. This is the code:

private class ViewDataTableTask extends AsyncTask<Void, Void, String> {
    ...

    protected String doInBackground(Void... params) {

        Cursor listCursor = db.rawQuery("SELECT ..." , null);
        ListView table_body = new ListView(context);

        try{
            table_body.setAdapter(new MyAdapter(context , listCursor));
        }finally{
             if(listCursor != null){
             listCursor.close();
        }
        ...
   }
   ...
}

MyAdapter is a custom CursorAdapter that uses the getView() and newView() method

If i run the previous code i get the following error:

java.lang.IllegalStateException: attempt to re-open 
an already-closed object: android.database.sqlite.SQLiteQuery

It seems that getView() and newView() method run on UI Thread!!!!!!

The question is simple: where have i to put cursor.close()?
I don’t want to use CursorLoader and/or startManagingCursor(..)

Please help me!!!

  • 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-13T09:53:14+00:00Added an answer on June 13, 2026 at 9:53 am

    The got Cursor instance will be used by CursorAdapter for as long as user uses your listView. That’s why you should not close the cursor so early. Whenever your instance of Activity is about to be destroyed it is time to close that cursor. Or whenever you change the cursor (if this is a case for your app) for that CursorAdapter, close the previously used.

    And as others say reset the cursor to CursorAdapter on the UI thread (in AsyncTask.onPostExecute()).

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

Sidebar

Related Questions

This is a C# problem. I have a big object in memory at a
I have a very big problem solving this issue I have 2 tables first
I have big problem when I am trying to deploy my app over clickonce.
I'm using editor from Kendo UI, so I have big problem. I don't know
I have a big problem. I use excel auto filter function, at the end
I have a big problem that a recursive treeview doesn't update any childs if
I have a big problem with my app as it crashes often but never
I have a big problem. I had a configuration which worked properly till today.
I have a big problem that is I have implemented a scheduler in my
I have a big problem. I want to extract text from html table that

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.