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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:58:00+00:00 2026-05-15T21:58:00+00:00

I’m using an sqlite database in my app. I have this dbhelper class in

  • 0

I’m using an sqlite database in my app. I have this dbhelper class in a services class like so.

    public class MushroomService {

        private int downloadprogress;
        private int databasesize;

        private DataBaseHelper myDbHelper;
    }

    public MushroomService(Context context)
    {
        myDbHelper = new DataBaseHelper(context);
        downloadprogress = 0;
    }

The services class is a member of my application class like so:

public class fungifieldguideapplication extends Application {
    public MushroomService service = new MushroomService(this);
}

In my activity classes I access and keep this application as a local variable like so:

public class Cat_Genus extends Activity {
    fungifieldguideapplication appState;
    ListView list_Genus;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.cat_genus);

        appState = ((fungifieldguideapplication)this.getApplication());

        Cursor cursor_genuslist = appState.service.GetGenusList(this);
        startManagingCursor(cursor_genuslist);
    }
}

and my service call looks like this:

public Cursor GetGenusList(Context context)
    {
        myDbHelper = new DataBaseHelper(context);
        Cursor cursor;
        try 
        {
            myDbHelper.openDataBase();
            SQLiteDatabase db = myDbHelper.myDataBase;
            cursor = db.query(true, "Mushrooms", GenusListColumns, null, null, "Genus", null, "Genus ASC", null);
        }
        catch(SQLException sqle)
        {
            throw sqle;
        }
        return cursor;
    }

I’ve added these overrides in to try to get rid of my memory leaks.

@Override
    public void onDestroy() {
        list_Genus.setAdapter(null);
        appState.service.CloseDB();
        super.onDestroy();
    }

    @Override
    public void onPause() {
        appState.service.CloseDB();
        super.onPause();
    }

    @Override
    public void onResume() {
        appState.service.OpenDB();
        super.onResume();
    }

But I can’t get my memory leaks to stop. Could somebody help me figure out how to rid myself of these memory leaks? These leaks are of the type:

07-27 17:38:44.613: ERROR/Database(26175): Leak found
07-27 17:38:44.613: ERROR/Database(26175): java.lang.IllegalStateException: /data/data/net.daleroy.fungifieldguide/databases/Mushrooms.db SQLiteDatabase created and never closed
07-27 17:38:44.613: ERROR/Database(26175):     at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1695)
07-27 17:38:44.613: ERROR/Database(26175):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:739)
07-27 17:38:44.613: ERROR/Database(26175):     at net.daleroy.fungifieldguide.data.DataBaseHelper.openDataBase(DataBaseHelper.java:79)
07-27 17:38:44.613: ERROR/Database(26175):     at net.daleroy.fungifieldguide.services.MushroomService.GetSpeciesListByGenus(MushroomService.java:113)
07-27 17:38:44.613: ERROR/Database(26175):     at net.daleroy.fungifieldguide.activities.Cat_Species.onCreate(Cat_Species.java:46)
07-27 17:38:44.613: ERROR/Database(26175):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-27 17:38:44.613: ERROR/Database(26175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
07-27 17:38:44.613: ERROR/Database(26175):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
07-27 17:38:44.613: ERROR/Database(26175):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-27 17:38:44.613: ERROR/Database(26175):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
07-27 17:38:44.613: ERROR/Database(26175):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-27 17:38:44.613: ERROR/Database(26175):     at android.os.Looper.loop(Looper.java:123)
07-27 17:38:44.613: ERROR/Database(26175):     at android.app.ActivityThread.main(ActivityThread.java:4363)
07-27 17:38:44.613: ERROR/Database(26175):     at java.lang.reflect.Method.invokeNative(Native Method)
07-27 17:38:44.613: ERROR/Database(26175):     at java.lang.reflect.Method.invoke(Method.java:521)
07-27 17:38:44.613: ERROR/Database(26175):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-27 17:38:44.613: ERROR/Database(26175):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-27 17:38:44.613: ERROR/Database(26175):     at dalvik.system.NativeStart.main(Native Method)
  • 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-15T21:58:01+00:00Added an answer on May 15, 2026 at 9:58 pm

    Maybe I’m wrong but perhaps its because you’re not closing the database after interacting with it. When ever I’m doing db work on android I surround interactions in a Try { } Finally { } clause which closes connection on finally.

    e.g

    try{
    //database stuff
    } finally{
       db.close
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 460k
  • Answers 460k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer <?php $req_dump = print_r($_REQUEST, TRUE); $fp = fopen('request.log', 'a'); fwrite($fp,… May 15, 2026 at 11:48 pm
  • Editorial Team
    Editorial Team added an answer You have to escape the spaces with a \. D:/FMOD\… May 15, 2026 at 11:48 pm
  • Editorial Team
    Editorial Team added an answer You need to use CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt to also capture… May 15, 2026 at 11:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.