title: How to insert bulk data in android sqlite database using ormlite efficiently
body: <p>I'm trying to insert 100000 records in android sqlite database at a time. I'm using following two different methods. </p>
  
  <pre><code> private void bulkInsertDataBySavePoint(final List&lt;User&gt; users) {
      log.debug("bulkInsertDataBySavePoint()");
      DatabaseConnection conn = null;
      Savepoint savepoint = null;
      try {
          conn = userDao.startThreadConnection();
          savepoint = conn.setSavePoint("bulk_insert");
          for (User user : users) {
              userDao.create(user);
          }
      } catch (SQLException e) {
          log.error("Something went wrong in bulk Insert", e);
      } finally {
          if (conn != null) {
              try {
                  conn.commit(savepoint);
                  userDao.endThreadConnection(conn);
              } catch (SQLException e) {
                  log.error("Something went wrong in bulk Insert", e);
              }
          }
      }
  }
  </code></pre>
  
  <p>And </p>
  
  <pre><code>   private void bulkInsertDataByCallBatchTasks(final List&lt;User&gt; users) {
      log.debug("bulkInsertDataByCallBatchTasks()");
      try {
          userDao.callBatchTasks(new Callable&lt;Void&gt;() {
              @Override
              public Void call() throws Exception {
                  for (User user : users) {
                      userDao.create(user);
                  }
                  return null;
              }
          });
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Both methods work fine. On average they take 140 seconds and take 60-65% CPU which is not ok, I think. </p>
  
  <p>The idea is, I have to consume an api which will provide json data. I have to parse that json data and then insert into sqlite database for offline usage. </p>
  
  <p>I'm looking for an efficient way to solve this issue. </p>
  
  <p>Any thought?</p>