How can we insert multiple rows into a Sqlite database at once? I am using Android with Java.
What you are looking for is this bulkInsert. It will allow you to provide an array ContentValuesfor insertion. See Android docs for more info:
bulkInsert
ContentValues
http://developer.android.com/reference/android/content/ContentResolver.html#bulkInsert%28android.net.Uri,%20android.content.ContentValues%5B%5D%29
you can use inserthelper check blog
ContentValues values = new ContentValues(); for(int i = 0; i<=5; i++) { values.put(COLUMN_NAME, i); values.put(COLUMN_NAME, 0); db.insert(TABLE_NAME, null, values); }
Very old post. When you try to make several calls in db, such as update or insert, wrap with transactions. This will make a huge difference in speed.
db.beginTransaction(); try { while(...) { // .. do your inserts, updates and deletes here } // If successful commit those changes db.setTransactionSuccessful(); } finally { db.endTransaction(); }