Master-detail Using ContentResolver.applyBatch()?

前端 未结 1 1712
小鲜肉
小鲜肉 2020-12-24 13:40

I was wondering if its possible to save master and detail records to a content provider using the android.content.ContentResolver.applyBatch() method in the same operation

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 14:18

    Each result produced from an item in the operations array is identified by its index in the array. Subsequent operations may reference those results via the withValueBackReference() method.

    .withValue(Detail.MASTER_ID, /* WHAT GOES HERE? */)
    

    becomes

    .withValueBackReference(Detail.MASTER_ID, 0)
    

    A complete example of this usage can be found in sample ContactManager. The 0 is the index of the ContentProviderOperation from which the value is obtained.

    0 讨论(0)
提交回复
热议问题