0

Based on the description of bulkInsert [1], it says:

 This function make no guarantees about the atomicity of the insertions.

I think what it actually does it, inserting rows one-by-one. Here comes the question: does it really improves performance, compared to calling insert [2] one-by-one, since they are actually doing the same thing?

[1] https://developer.android.com/reference/android/content/ContentResolver#bulkInsert(android.net.Uri,%20android.content.ContentValues[])

[2] https://developer.android.com/reference/android/content/ContentResolver#insert(android.net.Uri,%20android.content.ContentValues)

1 Answers1

0

Assuming its not a custom content provider that overrides the bulkInsert method there is no difference.

Where the difference comes is when its a custom provider where bulkInsert is overridden and a transaction is created which will perform better than doing regular insert

See: What is the point of ContentResolver.bulkInsert(..)?

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • bulkInsert saves Interprocess Communications (IPC) and only occupies only one thread. Does this make any difference? – Yiming Sun Mar 31 '21 at 17:21
  • For example, my code calls ContentResolver N times if I want to insert using `insert`, whereas only one time if I use `bulkInsert`; – Yiming Sun Mar 31 '21 at 17:22