3
HTCデバイスに連絡先を挿入する際に問題があります。 他のデバイスで正常に動作するように見えます。 私からのコードを使用しています:Inserting contacts in Android 2.2HTCに連絡先を挿入する
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
int rawContactInsertIndex = ops.size();
ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
.withValue(RawContacts.ACCOUNT_TYPE, null)
.withValue(RawContacts.ACCOUNT_NAME,null)
.build());
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, rawContactInsertIndex)
.withValue(Data.MIMETYPE,Phone.CONTENT_ITEM_TYPE)
.withValue(Phone.NUMBER, "9X-XXXXXXXXX")
.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());
ContentProviderResult[] res = getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
と私は取得しています:
07-18 09:37:49.832: ERROR/DatabaseUtils(209): Writing exception to parcel
07-18 09:37:49.832: ERROR/DatabaseUtils(209): java.lang.NullPointerException
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.HtcContactsProvider2$PhoneDataRowHandler.insert(HtcContactsPr ovider2.java:4614)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.ContactsProvider2.insertData(ContactsProvider2.java:3599)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.ContactsProvider2.insertInTransaction(ContactsProvider2.java:3394)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.CContactsProvider2.insertInTransaction(CContactsProvider2.java:191)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.HtcContactsProvider2.insertInTransaction(HtcContactsProvider2.java:1677)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.SQLiteContentProvider.insert(SQLiteContentProvider.java:106)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.ContactsProvider2.insert(ContactsProvider2.java:3159)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.CContactsProvider2.insert(CContactsProvider2.java:117)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at android.content.ContentProviderOperation.apply(ContentProviderOperation.java:214)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.SQLiteContentProvider.applyBatch(SQLiteContentProvider.java:216)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.ContactsProvider2.applyBatch(ContactsProvider2.java:3193)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at com.android.providers.contacts.CContactsProvider2.applyBatch(CContactsProvider2.java:145)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at android.content.ContentProvider$Transport.applyBatch(ContentProvider.java:199)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:202)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at android.os.Binder.execTransact(Binder.java:288)
07-18 09:37:49.832: ERROR/DatabaseUtils(209): at dalvik.system.NativeStart.run(Native Method)