title: Fastest and most efficient way to pre-populate database in Android
body: <p>If you want to pre-populate a database (SQLite) in Android, this is not that easy as one might think.</p>
  
  <p>So I found <a href="http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/">this tutorial</a> which is often referenced here on Stack Overflow as well.</p>
  
  <p>But I don't really like that way of pre-populating the database since you take the control from the database handler and create the files yourself. I would prefer to not touch the file system and let the database handler do everything on its own.</p>
  
  <p>So what I thought one could do is create the database in the database handler's onCreate() as usual but then load a file (.sql) from /assets which contains the statements to fill in the values:</p>
  
  <pre><code>INSERT INTO testTable (name, pet) VALUES ('Mike', 'Tiger');
  INSERT INTO testTable (name, pet) VALUES ('Tom', 'Cat');
  ...
  </code></pre>
  
  <p>But calling execSQL() in the handler's onCreate() doesn't really work. It seems that the /assets file must not have more than 1MB and the execSQL() only executes the first statement (Mike - Tiger).</p>
  
  <p>What would you do do pre-populate the database?</p>