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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:38:33+00:00 2026-05-31T14:38:33+00:00

I have this error with an sqlite-related cursor. i subclass SQLiteOpenHelper to get access

  • 0

I have this error with an sqlite-related cursor. i subclass SQLiteOpenHelper to get access to the database. Then, I access the DB and close my cursor directly afterwards. nevertheless, this results in an error when I close the activity:

The code looks like this:

String sql = "SELECT * FROM table_bla LIMIT 1";
Cursor cursor = dbHelper.getWritableDatabase().rawQuery(sql, null);

cursor.moveToFirst();
String x = cursor.getString(cursor.getColumnIndex("x"));
cursor.close();

And I get this:

03-14 15:34:55.945: E/Database(3825): close() was never explicitly called on database '/data/data/my.project/databases/myDB.db' 
03-14 15:34:55.945: E/Database(3825): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
03-14 15:34:55.945: E/Database(3825):   at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1847)
03-14 15:34:55.945: E/Database(3825):   at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
03-14 15:34:55.945: E/Database(3825):   at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:854)
03-14 15:34:55.945: E/Database(3825):   at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:847)
03-14 15:34:55.945: E/Database(3825):   at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:572)
03-14 15:34:55.945: E/Database(3825):   at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
03-14 15:34:55.945: E/Database(3825):   at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
03-14 15:34:55.945: E/Database(3825):   at my.project.StartScreen.onResume(StartScreen.java:35)
03-14 15:34:55.945: E/Database(3825):   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
03-14 15:34:55.945: E/Database(3825):   at android.app.Activity.performResume(Activity.java:3832)
03-14 15:34:55.945: E/Database(3825):   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2231)
03-14 15:34:55.945: E/Database(3825):   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2256)
03-14 15:34:55.945: E/Database(3825):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1789)
03-14 15:34:55.945: E/Database(3825):   at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-14 15:34:55.945: E/Database(3825):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
03-14 15:34:55.945: E/Database(3825):   at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 15:34:55.945: E/Database(3825):   at android.os.Looper.loop(Looper.java:130)
03-14 15:34:55.945: E/Database(3825):   at android.app.ActivityThread.main(ActivityThread.java:3835)
03-14 15:34:55.945: E/Database(3825):   at java.lang.reflect.Method.invokeNative(Native Method)
03-14 15:34:55.945: E/Database(3825):   at java.lang.reflect.Method.invoke(Method.java:507)
03-14 15:34:55.945: E/Database(3825):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
03-14 15:34:55.945: E/Database(3825):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
03-14 15:34:55.945: E/Database(3825):   at dalvik.system.NativeStart.main(Native Method)

anyone knows what causes this?

  • 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-31T14:38:35+00:00Added an answer on May 31, 2026 at 2:38 pm

    Rewrite your code like that:

    String sql = "SELECT * FROM table_bla LIMIT 1";
    SQLiteDatabase database = dbHelper.getWritableDatabase();
    Cursor cursor = database.rawQuery(sql, null);
    
    cursor.moveToFirst();
    String x = cursor.getString(cursor.getColumnIndex("x"));
    cursor.close();
    database.close();
    

    Otherwise you get a connection to the database you never close, which causes the problem.

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

Sidebar

Related Questions

I have this error: 12-07 15:27:11.567: E/AndroidRuntime(15797): Caused by: android.database.sqlite.SQLiteException: no such column: recipient:
I have this code and I couldn't run it because i get this error:
I'm using an sqlite database in my app. I have this dbhelper class in
i have created database in sqlite manager. my project get terminated due to exception.
I have closed the database in my adapter class, so whay is this error
I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide
I have this error that is keeping me from moving forward. I basically have
I have this error message could not load assembly 'system.data.entity, version 4.2.0.0, culture=neutral,publickeytoken=b77a5c561934e089' or
I have this error when I am trying to read the file: Exception in
I have this error appearing in my web service and even though I'v had

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.