Fastest and most efficient way to pre-populate database in Android

后端 未结 7 1377
清歌不尽
清歌不尽 2020-12-28 19:43

If you want to pre-populate a database (SQLite) in Android, this is not that easy as one might think.

So I found this tutorial which is often referenced here on Stac

7条回答
  •  天涯浪人
    2020-12-28 20:05

    I suggest the following:

    1. Wrap all of your INSERT logic into a transaction (BEGIN... COMMIT, or via the beginTransaction()... endTransaction() APIs)
    2. As already suggested, utilize the bind APIs and recycle objects.
    3. Don't create any indexes until after this bulk insert is complete.

    Additionally take a look at Faster bulk inserts in sqlite3?

提交回复
热议问题