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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:57:52+00:00 2026-06-19T01:57:52+00:00

Good evening! I’m trying to read from a SQLite database i just created in

  • 0

Good evening!

I’m trying to read from a SQLite database i just created in my android project. I create the database and enter data without any problems (I think). I query the db to get the data without any runtime complanints and i get a cursor returned from the method call. But the application crashes when i try to use the cursor. “Thread exiting with uncaught exception (group=0x416b72a0).

This is the code i’m trying to run. The toString of the cursor is working fine.

 TransactionSQLOH helper = new TransactionSQLOH(context, getDbName(yearS, monthS));
    SQLiteDatabase db = helper.getReadableDatabase();
    String[] columns = {"amount", "label", "year", "month", "day", "categoryID", "type", "ID", "time"};
    Cursor cursor = db.query(TransactionSQLOH.TABLE_NAME, columns, null, null, null, null, null);
    System.out.println(db);
    helper.close();
    System.out.println("Transaction_Check3.1");
    if (cursor == null){
        return null;
    }
    System.out.println("Transaction_Check3.2");
    System.out.println(cursor);
    int test = cursor.getCount();
    System.out.println("Transaction_Check3.3");
    Transaction[] result = new Transaction[10];  

I get the errror at the line

int test = cursor.getCount(); 

Help would be greatly appreciated 🙂

Edit, log:

   02-19 21:08:11.273: I/System.out(21558): Transaction_Check1
   02-19 21:08:11.283: I/System.out(21558): Transaction_Check2
   02-19 21:08:11.283: I/System.out(21558): SQLiteDatabase:                      /data/data/com.SverkerSbrg.Spendo/databases/transactions_201301
   02-19 21:08:11.283: I/System.out(21558): Transaction_Check3
   02-19 21:08:11.288: I/System.out(21558): Transaction_Check3.1
   02-19 21:08:11.288: I/System.out(21558): Transaction_Check3.2
   02-19 21:08:11.288: I/System.out(21558): android.database.sqlite.SQLiteCursor@421107d8
   02-19 21:08:11.288: I/System.out(21558): Transaction_Check3.3
   02-19 21:08:11.288: I/System.out(21558): Transaction_Check4
   02-19 21:08:11.288: D/AndroidRuntime(21558): Shutting down VM
   02-19 21:08:11.288: W/dalvikvm(21558): threadid=1: thread exiting with uncaught exception (group=0x416b72a0)
   02-19 21:08:11.328: E/AndroidRuntime(21558): FATAL EXCEPTION: main
   02-19 21:08:11.328: E/AndroidRuntime(21558): java.lang.IllegalStateException: Could not execute method of the activity
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.view.View$1.onClick(View.java:3704)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.view.View.performClick(View.java:4232)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.view.View$PerformClick.run(View.java:17298)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.os.Handler.handleCallback(Handler.java:615)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.os.Handler.dispatchMessage(Handler.java:92)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.os.Looper.loop(Looper.java:137)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.app.ActivityThread.main(ActivityThread.java:4921)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at java.lang.reflect.Method.invokeNative(Native Method)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at java.lang.reflect.Method.invoke(Method.java:511)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at dalvik.system.NativeStart.main(Native Method)
   02-19 21:08:11.328: E/AndroidRuntime(21558): Caused by: java.lang.reflect.InvocationTargetException
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at java.lang.reflect.Method.invokeNative(Native Method)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at java.lang.reflect.Method.invoke(Method.java:511)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.view.View$1.onClick(View.java:3699)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     ... 11 more
   02-19 21:08:11.328: E/AndroidRuntime(21558): Caused by: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:972)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:609)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:349)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:196)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:236)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at com.SverkerSbrg.Spendo.Datastructures.Transaction.getMonthTransaciton(Transaction.java:88)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     at com.SverkerSbrg.Spendo.MainActivity.btn2_click(MainActivity.java:43)
   02-19 21:08:11.328: E/AndroidRuntime(21558):     ... 14 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-19T01:57:53+00:00Added an answer on June 19, 2026 at 1:57 am

    Move:

    helper.close();
    

    To after:

    int test = cursor.getCount();
    

    You are getting an IllegalStateException exception because you are trying to use a Cursor after the SQLiteOpenHelper that accesses the db for it has been closed. This results in an error.

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

Sidebar

Related Questions

Good evening guys. I'm currently trying to get started on development of a project
Good evening, I have used BeautifulSoup to extract some data from a website as
Good evening. When I attempt to create jpa entities using a database connection I
Good evening, I wrote the code below in C to read and print from
Good evening, I created a class which inherits from UIViewController and i created a
Good evening, I am still working on my project (trying to improve myself harder.)
Good evening, I just started playing with Microsoft.Contracts (latest version) and plugging it on
Good evening, I'm trying to make a single php page wich can edit/delete multiple
Good evening, I've been trying to fix this bug for a few hours now
Good evening! Using Cargo via Maven, I've configured my pom.xml to create an instance

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.