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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:05:40+00:00 2026-06-08T04:05:40+00:00

I have a problem that has been driving me crazy and I’d appreciate any

  • 0

I have a problem that has been driving me crazy and I’d appreciate any thoughts you guys may have to offer. I import data from a CSV file (using openCSV) into a database, and previously this process has been completed in about 3-5 seconds including the download time from a server. The CSV file has 3035 records. I’ve tried separating the parsing from CSV and inserting to the table, but to no avail.

As strange as it may sound suddenly something has changed within my application where now this process takes much much longer.

After narrowing it down I’ve found that inserting into the table is extremely slow for SQLite. I’ve spent the last couple hours reverting back to older code to see if something has changed but to no luck.

I came across some similar question whose answer suggest me to use InsertHelper, which I did. Which made absolutely no difference in the import time. Currently inserting data takes 60 seconds, where it used to take just a couple.

public void importFromCSV() 
{
    SQLiteDatabase db = this.getReadableDatabase();
    db.execSQL("DELETE FROM EXAMS");
    File SDCardRoot = Environment.getExternalStorageDirectory();
    File file = new File(SDCardRoot.getAbsolutePath() + "/Finals/Data/timetable.csv");
    CSVReader reader;
    int i = 0;
    try {
        reader = new CSVReader(new FileReader(file));
        String [] nextLine;
        while ((nextLine = reader.readNext()) != null) {                
            this.addExam(new Exam(nextLine[0],
                                  nextLine[1],
                                  nextLine[2],
                                  nextLine[3],
                                  nextLine[4],
                                  nextLine[5],
                                  nextLine[6],
                                  nextLine[7],
                                  nextLine[8],
                                  nextLine[9]));
        }           

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }



}

public void addExam(Exam exam) {
    SQLiteDatabase db = this.getReadableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_SESSION, exam.getSession());
    values.put(KEY_AWARDING_BODY, exam.getAwardingBody());
    values.put(KEY_QUALIFICATION, exam.getQualification());
    values.put(KEY_TITLE, exam.getTitle());
    values.put(KEY_EXAM_CODE, exam.getExamCode());
    values.put(KEY_DURATION, exam.getDuration());
    values.put(KEY_DATE, exam.getDate());
    values.put(KEY_START_TIME, exam.getStartTime());
    values.put(KEY_EXAM_NOTE, exam.getExamNote());
    values.put(KEY_MY_NOTES, exam.getMyNotes()); 
    db.insert(TABLE_NAME, null, values);

}
  • 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-08T04:05:44+00:00Added an answer on June 8, 2026 at 4:05 am

    Your inserts may be slow because you are having to set up your references for every insert. Jeff Sharkey actually just talked about this problem in length at Google IO 1012. https://developers.google.com/events/io/sessions/gooio2012/103/ Basically you should be wrapping everything up in as few transactions as possible.

    try{
      db.beginTransaction();
      for each record in the list {
         do_some_processing();
         if (line represent a valid  entry) {
            db.insert(SOME_TABLE, null, SOME_VALUE);
         }
         some_other_processing();
      }
      db.setTransactionSuccessful();
    } catch (SQLException e) {
    } finally {
      db.endTranscation();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that has been driving me batty. I have code that
I have a problem that has been driving me nuts for days.. I've tried
I have a problem that has been driving me nuts. I create a Form
This problem has been driving me mad. Here's the general gist: I have two
This has been driving me nuts all day. I have a weird bug that
I have a problem that is and has been perplexing me for hours. I
I'm running into a little problem that's driving me crazy, and I'd welcome any
I have a javascript function that has been driving me nuts. This is the
I have been going crazy over a problem with my tab control. It has
I have had this problem for a while and it has been driving me

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.