Android - How can I pass data related to two tables to a the insert method of a Content Provider

后端 未结 3 1579
一整个雨季
一整个雨季 2020-12-10 23:01

I need to insert data related to an Order and its corresponding Detail.

Without a ContentProvider I would do something like t

3条回答
  •  情书的邮戳
    2020-12-10 23:25

    You should use ContentProviderOperation. Since it's your ContentProvider you can assure that applyBatch() will execute all operations within a transaction. All standard content providers also ensure that that's the case.

    See my blog post about ContentProviderOperation in general and my other post about how to use withBackReference() to access results of previous operations - which you need to access the orderId.

    One important caveat: All ContentProviderOperations of one batch must use the same authority - but can use different URIs! In your case that should be no problem.

提交回复
热议问题