我开发了一个同步应用程序,一切运行良好但只有一个问题。
public static void addContact(Context context, MyContact contact) {
ContentResolver resolver = context.getContentResolver();
resolver.delete(RawContacts.CONTENT_URI, RawContacts.ACCOUNT_TYPE + " = ?", new String[]{AccountGeneral.ACCOUNT_TYPE});
“MyContact contact”不起作用,每当我调用它时它会显示false,例如,如果我调用contact.name它将返回false
这是我发送联系信息的方式
for (int i = 0; i < mtcontacts.length(); i++) {
JSONObject mycontacts = mtcontacts.getJSONObject(i);
String name = mycontacts.getString("name");
String id = mycontacts.getString("id");
String email = mycontacts.getString("email");
String company = mycontacts.getString("company");
String job = mycontacts.getString("job");
String phone = mycontacts.getString("phone");
String fax = mycontacts.getString("fax");
String mobile = mycontacts.getString("mobile");
String website = mycontacts.getString("website");
String address = mycontacts.getString("street");
ContactsManager.addContact(NewActivity.this, new MyContact(name, email, mobile, company, job, phone, fax, website, address));
MyContact看起来像这样
public String name;
public String email;
public String company;
public String job;
public String mobile;
public String phone;
public String website;
public String address;
public String fax;
public long id;
public MyContact(String address, String email, String mobile, String company, String job, String phone, String fax, String website, String name) {
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
this.website = website;
this.job = job;
this.company = company;
this.mobile = mobile;
this.fax = fax;
}
}
有没有人知道如何制作
答案 0 :(得分:0)
解决了我需要做的就是重命名我的字符串
...
public String name;
public String email;
public String phone;
public MyContact(String address1, String email1, String name1) {
this.name = name1;
this.phone = phone1;
this.email = email1;
}
...