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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:04:18+00:00 2026-06-17T22:04:18+00:00

I’m writing a ListActivity, and I keep getting an IllegalStateException about trying to reopen

  • 0

I’m writing a ListActivity, and I keep getting an IllegalStateException about trying to reopen a closed object. (The error points to my setListAdapter() method.) Any ideas? I’ve tried using startManagingCursor() as well as calling cursor.close() in onPause(), but nothing get rid of the error.

NewsActivity.class

package com.lakesidebaptist.lakesidelife.ui.Content;

import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.widget.SimpleCursorAdapter;
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
import android.view.View;
import android.widget.ListView;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockListActivity;
import com.actionbarsherlock.view.MenuItem;
import com.lakesidebaptist.lakesidelife.MainActivity;
import com.lakesidebaptist.lakesidelife.R;
import com.lakesidebaptist.lakesidelife.update.database.dbAdapter;

/**
 * The activity that shows all the news items.
 * 
 * @author andrew
 */
public class NewsActivity extends SherlockListActivity {

    private Cursor cursor = null;
    private SimpleCursorAdapter adapter = null;
    dbAdapter dba = null;

    // Arrays
    private static String[] FROM = {"title", "body"};
    private static int[] TO = {R.id.news_title, R.id.news_body};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActionBar actionBar = getSupportActionBar();

        // Makes home button visible
        actionBar.setHomeButtonEnabled(true);

        // Allows home button to be used to navigate up
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    /*
     * This method is called when the user clicks the home button to go back. It
     * stops this activity and returns the user to the home screen.
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        onStop();
        return true;
    }

    @Override
    protected void onPause() {
        super.onPause();
        //dba.close();
    }

    @Override
    protected void onResume() {
        super.onResume();

        //Setting up the database adapter
        dba = new dbAdapter(this);
        dba.open();

        // Getting the Cursor of the requested data
        cursor = dba.read("news", null, null);
        //startManagingCursor(cursor);
        adapter = new SimpleCursorAdapter(this, R.layout.news_list, cursor, FROM, TO, 0);
        setListAdapter(adapter);
        setTitle(R.string.news);
    }
}

Logcat

01-27 21:41:42.330: E/AndroidRuntime(986): FATAL EXCEPTION: main
01-27 21:41:42.330: E/AndroidRuntime(986): java.lang.RuntimeException: Unable to resume activity {com.lakesidebaptist.lakesidelife/com.lakesidebaptist.lakesidelife.ui.Content.NewsActivity}: java.lang.IllegalStateException: attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery (mSql = SELECT * FROM 'news';) 
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.os.Looper.loop(Looper.java:123)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-27 21:41:42.330: E/AndroidRuntime(986):  at java.lang.reflect.Method.invokeNative(Native Method)
01-27 21:41:42.330: E/AndroidRuntime(986):  at java.lang.reflect.Method.invoke(Method.java:521)
01-27 21:41:42.330: E/AndroidRuntime(986):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-27 21:41:42.330: E/AndroidRuntime(986):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-27 21:41:42.330: E/AndroidRuntime(986):  at dalvik.system.NativeStart.main(Native Method)
01-27 21:41:42.330: E/AndroidRuntime(986): Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery (mSql = SELECT * FROM 'news';) 
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:34)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:64)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:283)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:264)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.support.v4.widget.CursorAdapter.getCount(CursorAdapter.java:202)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.widget.ListView.setAdapter(ListView.java:436)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ListActivity.setListAdapter(ListActivity.java:267)
01-27 21:41:42.330: E/AndroidRuntime(986):  at com.lakesidebaptist.lakesidelife.ui.Content.NewsActivity.onResume(NewsActivity.java:77)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.Activity.performResume(Activity.java:3823)
01-27 21:41:42.330: E/AndroidRuntime(986):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
01-27 21:41:42.330: E/AndroidRuntime(986):  ... 12 more
  • 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-17T22:04:19+00:00Added an answer on June 17, 2026 at 10:04 pm
    attempt to re-open an already-closed object: android.database.sqlite.SQLiteQuery (mSql = SELECT * FROM 'news';)
    

    Seems you are returning an already closed cursor here:

    cursor = dba.read("news", null, null);
    

    Check if you haven’t closed the cursor inside dbAdapter read() method.
    And if you post the dbAdapter class it would be helpful.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I am writing an app with both english and french support. The app requests

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.