jamesc
jamesc

Reputation: 12837

Android - Is it possible for a contentValue to be an array of contentValues?

I have a need to bulkInsert a lot of data

I'm using a content provider and wish to make use of the bulkInsert method (which I am overriding) to enable me to wrap the whole process inside a database transaction

The bulkInsert method takes an array of contentValues as it's parameter which is fine when dealing with a single table but I have a parent child relationship that I need to insert

The code I need for the actual insert is not the issue. what I'm struggling with is how to pass a 2 dimensional array of contentValues to the bulkInsert method of a content provider

If this is not possible to do then how would I use a contentProvider to bulk update 100 parent records each having a number of child records?

Possibly not relevant but just to provide a more complete picture - The data is coming in from a web service as a JSON response

Upvotes: 1

Views: 1208

Answers (1)

Vinay
Vinay

Reputation: 2415

My Suggestion to this would be, Insert all the parent info with one bulk insert. Once, you are done with parents, now call bulk insert of child for each parent.

Other way round, Insert a parent, get the row id for parent, use it for linking its children of this parent and bulk insert the data of child. But not sure, about the performance of this.

Upvotes: 1

Related Questions