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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:39:07+00:00 2026-06-11T18:39:07+00:00

I’m developping an application to store some bets made between two people. Now I’m

  • 0

I’m developping an application to store some bets made between two people.

Now I’m pretty much new into this and especially with SQLite. The problem is, I’m getting one of following ErrorMessages all the time, despite there are only 2 or 3 entries in my database.

No. 1

09-22 10:19:36.138: E/AndroidRuntime(21351): FATAL EXCEPTION: main
09-22 10:19:36.138: E/AndroidRuntime(21351): java.lang.OutOfMemoryError
09-22 10:19:36.138: E/AndroidRuntime(21351):    at java.util.Vector.newElementArray(Vector.java:120)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at java.util.Vector.growByOne(Vector.java:466)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at java.util.Vector.add(Vector.java:153)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at challenge.sql.CustomDataSource.getAllEntries(CustomDataSource.java:172)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at challenge.main.OverviewActivity.updateOverview(OverviewActivity.java:40)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at challenge.main.OverviewActivity.onCreate(OverviewActivity.java:29)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.Activity.performCreate(Activity.java:4465)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.os.Looper.loop(Looper.java:137)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at android.app.ActivityThread.main(ActivityThread.java:4340)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at java.lang.reflect.Method.invokeNative(Native Method)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at java.lang.reflect.Method.invoke(Method.java:511)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-22 10:19:36.138: E/AndroidRuntime(21351):    at dalvik.system.NativeStart.main(Native Method)

No. 2

09-22 10:19:20.308: E/AndroidRuntime(21337): FATAL EXCEPTION: main
09-22 10:19:20.308: E/AndroidRuntime(21337): java.lang.OutOfMemoryError: [memory exhausted]
09-22 10:19:20.308: E/AndroidRuntime(21337):    at dalvik.system.NativeStart.main(Native Method)
09-22 10:19:20.318: E/System(21337): Uncaught exception thrown by finalizer
09-22 10:19:20.378: E/System(21337): java.lang.IllegalStateException: Don't have database lock!
09-22 10:19:20.378: E/System(21337):    at android.database.sqlite.SQLiteDatabase.verifyLockOwner(SQLiteDatabase.java:2090)
09-22 10:19:20.378: E/System(21337):    at android.database.sqlite.SQLiteDatabase$1.entryRemoved(SQLiteDatabase.java:2182)
09-22 10:19:20.378: E/System(21337):    at android.database.sqlite.SQLiteDatabase$1.entryRemoved(SQLiteDatabase.java:2178)
09-22 10:19:20.378: E/System(21337):    at android.util.LruCache.trimToSize(LruCache.java:197)
09-22 10:19:20.378: E/System(21337):    at android.util.LruCache.evictAll(LruCache.java:285)
09-22 10:19:20.378: E/System(21337):    at android.database.sqlite.SQLiteDatabase.deallocCachedSqlStatements(SQLiteDatabase.java:2143)
09-22 10:19:20.378: E/System(21337):    at android.database.sqlite.SQLiteDatabase.closeClosable(SQLiteDatabase.java:1126)
09-22 10:19:20.378: E/System(21337):    at android.database.sqlite.SQLiteDatabase.finalize(SQLiteDatabase.java:1914)
09-22 10:19:20.378: E/System(21337):    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
09-22 10:19:20.378: E/System(21337):    at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
09-22 10:19:20.378: E/System(21337):    at java.lang.Thread.run(Thread.java:856)

No. 3

09-22 10:19:20.308: E/SQLiteDatabase(21337): close() was never explicitly called on database '/data/data/challenge.main/databases/DBCHALLENGES' 
09-22 10:19:20.308: E/SQLiteDatabase(21337): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1943)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1007)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:986)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1051)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:770)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:157)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at challenge.sql.CustomDataSource.open(CustomDataSource.java:33)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at challenge.main.OverviewActivity.updateOverview(OverviewActivity.java:38)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at challenge.main.OverviewActivity.onCreate(OverviewActivity.java:29)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.Activity.performCreate(Activity.java:4465)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.os.Looper.loop(Looper.java:137)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at android.app.ActivityThread.main(ActivityThread.java:4340)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at java.lang.reflect.Method.invokeNative(Native Method)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at java.lang.reflect.Method.invoke(Method.java:511)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    09-22 10:19:20.308: E/SQLiteDatabase(21337):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-22 10:19:20.308: E/SQLiteDatabase(21337):    at dalvik.system.NativeStart.main(Native Method)

Now the problem is – as I think – caused by the getAllEntries() in this method in my OverviewActivity class

public void updateOverview(){
        datasource = new CustomDataSource(this);
        datasource.open();
        Game game = datasource.getSpecificGame(challengeName);
        entries = datasource.getAllEntries();
        datasource.close();

            (...)
}

This is the Code in the CustomDataSource class

public Vector<FootballEntry> getAllEntries(){
    Vector<FootballEntry> entries = new Vector<FootballEntry>();

    Cursor cursor = database.query(CustomSQLiteHelper.TABLE_FOOTBALL, allColumns2, null, null, null, null, null);
    cursor.moveToFirst();

    while(!cursor.isAfterLast()){
        FootballEntry entry = cursorToEntry(cursor);
        entries.add(entry);
        cursor.moveToNext();
    }
    cursor.close();
    return entries;
}

private FootballEntry cursorToEntry(Cursor cursor){
    cursor.moveToFirst();
    FootballEntry game = new FootballEntry();
    game.setID(cursor.getLong(0));
    game.setDate(cursor.getString(1));
    game.setHome(cursor.getInt(2));
    game.setPlatform(cursor.getString(3));
    game.setTeam1(cursor.getString(4));
    game.setStars1(cursor.getDouble(5));
    game.setTeam2(cursor.getString(6));
    game.setStars2(cursor.getDouble(7));
    game.setGoals1(cursor.getInt(8));
    game.setGoals2(cursor.getInt(9));
    game.setFinished(cursor.getInt(10));
    return game;
 }

And here the constructor of CustomDataSource and the methods open() and close()

public CustomDataSource(Context context){
        dbHelper = new CustomSQLiteHelper(context);
}

public void open() throws SQLException{
        database = dbHelper.getWritableDatabase();
}

public void close(){
        dbHelper.close();
}

Note: I’ve read a few times, that my CustomSQLiteHelper should extend SQLiteOpenHelper, that is the case.

I do not exactly understand why this errors are thrown. Everytime I want to do work with the database, I create a new CustomDataSource, call open(), do work, and call close(). What’s the problem here? First I thought, the error is caused by puttin open() in the onResume() and close() in the onClose() method of my Activity, but removing them do not causes any differences. Also per activity I create only one instance of CustomDataSource, and after working with it, I close it.

  • 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-11T18:39:08+00:00Added an answer on June 11, 2026 at 6:39 pm

    Don’t call cursor.moveToFirst(); in method cursorToEntry because it turns your request into an infinite loop. So even if you have two records fetched from database, your current logic will keep on creating objects of those two records till the device runs out of memory.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.