综合实例-联系人信息管理

ContactsDemo.zip

准备知识

准备知识:
1.了解系统联系人的结构
2.表结构
方法:
1.查看电话应用的源码
2.利用搜索引擎查找相关信息
image.png
image.png
image.png
image.png
image.png

AndroidManifest.xml

image.png

PersonInfo.java

  1. package com.example.contactsdemo;
  2. public class PersonInfo {
  3. private int _id;
  4. private String name;
  5. private String email;
  6. private String phone;
  7. private String address;
  8. public int get_id() {
  9. return _id;
  10. }
  11. public void set_id(int _id) {
  12. this._id = _id;
  13. }
  14. public String getName() {
  15. return name;
  16. }
  17. public void setName(String name) {
  18. this.name = name;
  19. }
  20. public String getEmail() {
  21. return email;
  22. }
  23. public void setEmail(String email) {
  24. this.email = email;
  25. }
  26. public String getPhone() {
  27. return phone;
  28. }
  29. public void setPhone(String phone) {
  30. this.phone = phone;
  31. }
  32. public String getAddress() {
  33. return address;
  34. }
  35. public void setAddress(String address) {
  36. this.address = address;
  37. }
  38. @Override
  39. public String toString() {
  40. return "PersonInfo{" +
  41. "_id=" + _id +
  42. ", name='" + name + '\'' +
  43. ", email='" + email + '\'' +
  44. ", phone='" + phone + '\'' +
  45. ", address='" + address + '\'' +
  46. '}';
  47. }
  48. }

MainActivity.java

  1. package com.example.contactsdemo;
  2. public class PersonInfo {
  3. private int _id;
  4. private String name;
  5. private String email;
  6. private String phone;
  7. private String address;
  8. public int get_id() {
  9. return _id;
  10. }
  11. public void set_id(int _id) {
  12. this._id = _id;
  13. }
  14. public String getName() {
  15. return name;
  16. }
  17. public void setName(String name) {
  18. this.name = name;
  19. }
  20. public String getEmail() {
  21. return email;
  22. }
  23. public void setEmail(String email) {
  24. this.email = email;
  25. }
  26. public String getPhone() {
  27. return phone;
  28. }
  29. public void setPhone(String phone) {
  30. this.phone = phone;
  31. }
  32. public String getAddress() {
  33. return address;
  34. }
  35. public void setAddress(String address) {
  36. this.address = address;
  37. }
  38. @Override
  39. public String toString() {
  40. return "PersonInfo{" +
  41. "_id=" + _id +
  42. ", name='" + name + '\'' +
  43. ", email='" + email + '\'' +
  44. ", phone='" + phone + '\'' +
  45. ", address='" + address + '\'' +
  46. '}';
  47. }
  48. }

activity_main.xml

image.png