Monday, August 13, 2012

SQLite insert very slow Monodroid

SQLite is a transactional database that goes through the full cycle of file open, write and close unless you specifically tell it not to. Here is my batch add routine that greatly speeds up the rate at which records may be added. This key returns the autoincrement primary key of the last item inserted.


        public int AddRange(IEnumerable<Doodaa> list)
        {
           int n = 0;
           using (var database = new SQLiteConnection(_helper.WritableDatabase.Path))
           {
               database.BeginTransaction();
                foreach(Doodaa d in list)
                    n=database.Insert(d);
               database.Commit();
           }

            return n;
        }

1 comment:

darichkid said...

Bob

Here is a database compatible with MonoDroid:
http://www.kellermansoftware.com/p-43-ninja-net-database-pro.aspx