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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:49:37+00:00 2026-05-25T09:49:37+00:00

I know there are similar forum threads to this one, but I’ve read them

  • 0

I know there are similar forum threads to this one, but I’ve read them and tried the methods for solving the problem but it doesn’t seem to do it.
I get the:

close() was never explicity called on database /data/data…

application did not close the database or cursor that was opened…

My error does not occur directly, it happens after awhile, when I’ve gone back and forth between the two activities.

I use two activities which both need a connection to the database. My idea was for the first activity to close the database before the other activity starts. Here is my code:

@Override
public void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    movies = new MoviesData(this);
    cursor = getTitles();
    showTitles(cursor);
}

@Override
public void onPause() {
    movies.close();
    super.onPause();
}

@Override
public void onResume() {
    movies = new MoviesData(this);
    super.onResume();
}

This is my first activity, the second one is pretty much alike and is started upon a buttonpress. The MoviesData class is just an empty SQLiteOpenHelper class found below.

public class MoviesData extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "movies.db";
    private static final int DATABASE_VERSION = 1;

    public MoviesData(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
}

I now know when the error is displayed. If I quit the application and then open it again and try to do something the error is showing. I’ve tried to close the database in “onDestroy()” but that doesn’t help either…

  • 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-25T09:49:38+00:00Added an answer on May 25, 2026 at 9:49 am

    I made it work now!
    I just added this to my SQLiteOpenHelper class.

    public class MoviesData extends SQLiteOpenHelper {
        private static final String DATABASE_NAME = "movies.db";
        private static final int DATABASE_VERSION = 1;
    
        private static MoviesData movies;
    
        private MoviesData(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }
    
        public static MoviesData getInstance(Context context) {
            if (movies == null) {
                movies = new MoviesData(context);
            }
            return movies;
        }
    

    }

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

Sidebar

Related Questions

I know there are questions similar to this one, but I've not found a
I know there have been some similar questions to this, but they haven't helped
I know there are many questions similar but any of them didn't help. in
I know there a lot of similar questions to this, but I didn't find
I know there are several threads asking similar questions - but I havent found
I know there are other questions on the forum regarding this but found ho
I know there are similar questions about this topic,but somehow I'm not able to
I know there are a few similar questions to this but I just can't
I know there are other posts similar to this, but everyone recommends just doing
Ok, I know that there's been similar questions on this site about this problem,

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.