withValueBackReference简介
2011-12-16 11:07
183 查看
ContentProviderOperation.Builder的withValueBackReference函数定义如下:
示例1:
来源http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html
Note the use of
结束!
ContentProviderOperation.Builder | withValueBackReference(String key, int previousResult) Add a ContentValues back reference. 第一个参数key对应于数据库中的列名,第二个参数previousResult代表着:回引数据库批量操作中的第previousResult个数据库操作的返回值。 总的来说就是说把批量数据库操作中的第previousResult个数据库操作的返回值作为列名为key的记录的值 |
ContentProviderOperation.Builder | withValueBackReferences(ContentValues backReferences) Add a ContentValuesof back references. 同上,只是把2个参数封装成一个参数。 |
来源http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ... int rawContactInsertIndex = ops.size(); ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) .withValue(RawContacts.ACCOUNT_TYPE, accountType) .withValue(RawContacts.ACCOUNT_NAME, accountName) .build()); ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") .build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
Note the use of
withValueBackReference(String, int)to refer to the as-yet-unknown index value of the raw contact inserted in the first operation.
结束!
相关文章推荐
- withValueBackReference
- withValueBackReference的理解
- 个人对withValueBackReference的理解
- C# - test and cast with reference type or value...
- AS 导入jar包后运行出错:finished with non-zero exit value 3
- php5.3 的问题 “Assigning the return value of new by reference is deprecated in xxxx”
- building caffe with cudnn fails with undefined reference to `cudnnSetActivationDescriptor' error
- a different object with the same identifier value was already associated with the session错误
- Erlang:Error in process ... with exit value
- Android Studio 运行时出现 finished with non-zero exit value 2 终极解决方案
- rvalue references and Move semantics
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value
- [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_ti
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- Android问题:String types not allowed (at 'layout_gravity' with value 'top/right').
- java枚举类Enum方法简介(valueof,value,ordinal)
- 关于返回const value和const reference value
- 错误中学习--a different object with the same identifier value was already associated with the session
- Could not load the "start.png" image referenced from a nib in the bundle with identifier