private void toExecuteSave(){ Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType("vnd.android.cursor.dir/person"); intent.setType("vnd.android.cursor.dir/contact"); intent.setType("vnd.android.cursor.dir/raw_contact");// //添加姓名 intent.putExtra(Insert.NAME, mEmployee.getEmployeeName()+vUserName.getText()); // intent.putExtra(Insert.NOTES,mEmployee.getUserName()); // //添加職位// intent.putExtra(Insert.JOB_TITLE,mEmployee.getJobName());// //添加公司名稱// intent.putExtra(Insert.COMPANY,mEmployee.getOrgName()); // //添加郵箱// intent.putExtra(Insert.EMAIL_TYPE,Email.TYPE_WORK); // intent.putExtra(Insert.EMAIL,mEmployee.getOfficeEmail()); // //添加手機// intent.putExtra(Insert.PHONE_TYPE,Phone.TYPE_WORK_MOBILE);// intent.putExtra(Insert.PHONE, mEmployee.getMobile());// //添加辦公電話// intent.putExtra(Insert.SECONDARY_PHONE_TYPE,Phone.TYPE_WORK);// intent.putExtra(Insert.SECONDARY_PHONE, mEmployee.getOfficeTel());// //添加傳真// intent.putExtra(Insert.TERTIARY_PHONE_TYPE,Phone.TYPE_FAX_WORK);// intent.putExtra(Insert.TERTIARY_PHONE, mEmployee.getFax());// //添加地址// intent.putExtra(Insert.POSTAL,mEmployee.getAddress());// intent.putExtra(Insert.POSTAL_TYPE,StructuredPostal.TYPE_WORK); ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues values1 = new ContentValues(); values1.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); values1.put(StructuredName.PHONETIC_GIVEN_NAME, mEmployee.getEmployeeName()); values1.put(StructuredName.GIVEN_NAME, mEmployee.getEmployeeName()); values1.put(StructuredName.DISPLAY_NAME, mEmployee.getEmployeeName()); data.add(values1); // 添加使用者名稱 職位 部門 ContentValues values2 = new ContentValues(); values2.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE); values2.put(Organization.LABEL, mEmployee.getUserName()); values2.put(Organization.TITLE, mEmployee.getJobName()); values2.put(Organization.COMPANY, mEmployee.getOrgName()); values2.put(Organization.TYPE, Organization.TYPE_WORK); data.add(values2); // 添加郵箱 ContentValues values3 = new ContentValues(); values3.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE); values3.put(Email.DATA, mEmployee.getOfficeEmail()); values3.put(Email.TYPE, Email.TYPE_WORK); data.add(values3); // 添加手機 ContentValues values4 = new ContentValues(); if (mEmployee.getMobile().contains("或")) { final String[] tNumbers = mEmployee.getMobile().split("或"); for (String tNum : tNumbers) { values4.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); values4.put(Phone.NUMBER, tNum); values4.put(Phone.TYPE, Phone.TYPE_WORK_MOBILE); } } else { values4.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); values4.put(Phone.NUMBER, mEmployee.getMobile()); values4.put(Phone.TYPE, Phone.TYPE_WORK_MOBILE); } data.add(values4); // 添加固定電話 ContentValues values5 = new ContentValues(); values5.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); values5.put(Phone.NUMBER, mEmployee.getOfficeTel()); values5.put(Phone.TYPE, Phone.TYPE_WORK); data.add(values5); // 添加傳真 ContentValues values6 = new ContentValues(); values6.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); values6.put(Phone.NUMBER, mEmployee.getFax()); values6.put(Phone.TYPE, Phone.TYPE_FAX_WORK); data.add(values6); // 添加地址 郵編 ContentValues values7 = new ContentValues(); values7.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE); values7.put(StructuredPostal.FORMATTED_ADDRESS, mEmployee.getAddress()); values7.put(StructuredPostal.POSTCODE, mEmployee.getPostCode()); values7.put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK); data.add(values7); // 添加頭像 ContentValues values8 = new ContentValues(); values8.put(Data.MIMETYPE, Photo.CONTENT_ITEM_TYPE); // if (mEmployee.getGender().equals("2"))// 為女,儲存女性預設頭像 // values.put(Photo.PHOTO, // getDrawableToByte(R.drawable.oa_contact_head_f)); // else // 男 values8.put(Photo.PHOTO, getDrawableToByte(R.drawable.oa_contact_head_m)); data.add(values8); intent.putParcelableArrayListExtra(Insert.DATA, data); context.startActivity(intent); }