Bulk Insertion on Android device

后端 未结 5 833
刺人心
刺人心 2020-11-28 02:40

I want to bulk insert about 700 records into the Android database on my next upgrade. What\'s the most efficient way to do this? From various posts, I know that if I use <

5条回答
  •  广开言路
    2020-11-28 02:44

    I've found that for bulk insertions, the (apparently little-used) DatabaseUtils.InsertHelper class is several times faster than using SQLiteDatabase.insert.

    Two other optimizations also helped with my app's performance, though they may not be appropriate in all cases:

    • Don't bind values that are empty or null.
    • If you can be certain that it's safe to do it, temporarily turning off the database's internal locking can also help performance.

    I have a blog post with more details.

提交回复
热议问题