title: Populate Android Database From CSV file?
body: <p>Is it possible to take a csv file stored in the res/raw resource directory and use it to populate a table in the sqlite3 database?</p>
  
  <p>My thought was that, if there was a way to do a bulk import for the entire file into the table then that would be cleaner and faster than iterating over each line in the file and executing individual insert statements...</p>
  
  <p>I've found that there is a sqlite import command that allows this: <a href="https://stackoverflow.com/questions/1045910/how-can-i-import-load-a-sql-or-csv-file-into-sqlite">How to import load a .sql or .csv file into SQLite?</a></p>
  
  <p>...but I'm having trouble applying those statements in my Android application. My first thought was to try something like the following...but no luck:</p>
  
  <pre><code>db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, name TEXT)");
  db.execSQL(".mode csv");
  db.execSQL(".import res/raw/MyFile.csv " + TABLE_NAME); 
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>Should I be trying a different approach to populate my database?</p>
  
  <p>UPDATE: I'm marking Josef's response  as the answer (bulk insert using transactions) because it works fine and directly answers my question based on my title (thanks Josef). However, I'm am still looking for a way to do a bulk insert in an Android app from csv file into a sqlite3 table using the import statement.  If you know how to do this please respond.</p>
  
  <p>Thanks for you answers!</p>