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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:21:17+00:00 2026-05-28T16:21:17+00:00

My application parses three different XML’s and saves them to database. It worked fine

  • 0

My application parses three different XML’s and saves them to database. It worked fine as long as I used AsyncTask, with progress dialog, because all of them were executed one after another. I’m now starting to parse that data simultaneously in three different threads (+UI thread). Now these four threads fight for database, and sometimes crash, always if UI thread is being used. I get the following errors:

 ERROR/AndroidRuntime(651): Caused by: java.lang.IllegalStateException: database /data/data/edu.activity/databases/vreme already closed

then another time i get

 INFO/System.out(667): XML Pasing5 Excpetion = java.lang.IllegalStateException: database not open

or this one

01-30 00:56:05.232: ERROR/AndroidRuntime(731): FATAL EXCEPTION: Thread-11
01-30 00:56:05.232: ERROR/AndroidRuntime(731): java.lang.IllegalStateException: database not open
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1493)
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at edu.database.DBAdapter.insertSamodejne(DBAdapter.java:229)
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at edu.util.ApplicationInt.addDBSamodejne(ApplicationInt.java:49)
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at edu.xml.XMLtoDB.insertSamodejne(XMLtoDB.java:58)
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at edu.activity.SplashScreen$4.run(SplashScreen.java:97)
01-30 00:56:05.232: ERROR/AndroidRuntime(731):     at java.lang.Thread.run(Thread.java:1096)

I insert about 80 items every time I insert data, using this and similar methods:

public void addDBSplosna(SplosnaRazred s) {
      db.open();
      db.insertSplosna(s);
      db.close();  
}

DBAdapter:

   public long insertSplosna(SplosnaRazred splosna) {
        ContentValues initialValues = new ContentValues();

        initialValues.put(VREMENSKA, splosna.getVremenska());
        initialValues.put(OBETI, splosna.getObeti());
        initialValues.put(UPDATED, splosna.getServerUpdated());

        return db.insert(TABLE_SPLOS, null, initialValues);
    }

Is there a way to stop them from fighting for database? Should I lock the database until it’s done and then release it? If that’s the case, how to do 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-05-28T16:21:18+00:00Added an answer on May 28, 2026 at 4:21 pm

    you can make method addDBSplosna(SplosnaRazred s) synchronized, to be sure that only one thread at the time can write to DB.

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

Sidebar

Related Questions

I am currently working on an application that parses huge XML files. For each
In short,I've written an application that parses text files in specified formats from different
There is an application where I work that uses the Microsoft XML parser 3.0.
I created an application that parses content of secured areas of one webpage after
I have to develop an application which parses a log file and sends specific
I have written a Ruby application which parses lots of data from sources in
I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in
I have got an application, that is getting data via XML-files. During the parsing-part
I'm working on a SaaS application where each customer will have different configurations depending
I have a simple Windows Forms application which is used to calculate the solutions

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.