// 指定要添加的联系人的email
values.put(Email.DATA, emailText.getText().toString());
// 添加联系人的email
getContentResolver().insert(ContactsContract.Data.CONTENT_URI,
values);
}
finish();
}
if (v.getId() == R.id.add_contact_main_btn_back) {
finish();
}
}
}
增加联系人的Activity:
[html]
< xml version="1.0" encoding="utf-8" >
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_height="wrap_content"
android:text="联系人的姓名" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_height="wrap_content"
android:text="联系人的电话" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_height="wrap_content"
android:text="联系人的email" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" >
android:id="@+id/add_contact_main_btn_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click"
android:text="保存" />
android:id="@+id/add_contact_main_btn_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:onClick="click"
android:text="返回" />
< xml version="1.0" encoding="utf-8" >
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_height="wrap_content"
android:text="联系人的姓名" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_height="wrap_content"
android:text="联系人的电话" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:layout_height="wrap_content"
android:text="联系人的email" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />
android:l