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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:33:22+00:00 2026-05-29T11:33:22+00:00

I have an issue that has got me pretty stumped, and would appreciate some

  • 0

I have an issue that has got me pretty stumped, and would appreciate some input with. I have a thread in my app which inserts into a database from a csv file. Everything seems fine, but recently Im getting database not open stack traces sent to me from the developer console.

Its happining to a really small portion of my users, maybe 1 in a 100 have this issue, I can run the insert for hours before I finally see the error, and when I do theres no difference than what I did the other 80 times when it worked fine.

Heres the stack trace:

java.lang.IllegalStateException: database not open
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1615)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1515)
at com.ljworkshop.YugiohCompanion.DBAdapterCards.insertCard(DBAdapterCards.java:169)
at com.ljworkshop.YugiohCompanion.home$8.run(home.java:1020)
at java.lang.Thread.run(Thread.java:1027)

Heres the section of code:

 public void cardBaseupdate(String file,int amount) {



        final String files = file;
        final int amountf = amount;

        dialog = new ProgressDialog(home.this);
         dialog.setCancelable(false);
         dialog.setMessage("Populating Database");

         dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

         dialog.setProgress(0);

         dialog.setMax(amountf);

         dialog.show();

         Thread background = new Thread (new Runnable() {
             public void run() {


        InputStream data1 = null;

        try {
            data1 = getAssets().open(files);

        } catch (IOException e) {

            e.printStackTrace();
        } 

        BufferedReader in = new BufferedReader(new InputStreamReader(data1));
        String reader = "";
        try {
            while ((reader = in.readLine()) != null){
                Integer.toString(in.readLine().length()), 
                String[] RowData = reader.split(",");
                String name = RowData[0];
                String number = RowData[1];
                String series = RowData[2];
                String type = RowData[3];
                String element = RowData[4];
                String level = RowData[5];
                String spell = RowData[6];
                String att = RowData[7];
                String def= RowData[8];
                String rules = RowData[9];
                String legal = RowData[10];

                dbc.open();
                progressHandler.sendMessage(progressHandler.obtainMessage());


                dbc.insertCard(name,number,series,type,element,level,spell,att,def,rules,legal);


                dbc.close();
            }
        } catch (IOException e) {

            e.printStackTrace();
        }
        try {
            in.close();
        } catch (IOException e) {

            e.printStackTrace();
        }


        valueSet = true;

             }
         });    

         background.start();
  • 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-29T11:33:22+00:00Added an answer on May 29, 2026 at 11:33 am

    I hope when you say Thread, you mean you are using an AsyncTask. The reason for this is because an AsyncTask is optimized for android in threading.

    Ideally when you running your database logic, you want to insure that you close your database EVERYTIME by using the finally clause. This will ensure that it is closed each time it is opened during your logic.

    Also a thread is not a safe place to be doing database transactions, typically you run your logic (in a thread) and then update the database once you have new data.

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

Sidebar

Related Questions

I've got a bit of a usability issue that I'd value some input on.
I've got an interface inheritance issue that has been vexing me for some time.
I have got a Subquery issue that I am sure has a really really
I have a strange issue that has arisen recently: Whenever I enter text, even
I have a program that has 2 threads running, and each thread has its
So, I´ve got an issue that someone might have solved (or so I hope).
I've got some HTML which has some dynamically generated forms which are submitted via
We have already built a rails app that has several users and an image
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager

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.