[英]ContentResolver.requestSync in Sync Adapter is not working in Android
[英]Android Sync Adapter not working
我已经开发了一个同步应用程序,一切运行正常,但只有一个问题。
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联系人”不起作用,每次我调用它时都会显示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;
}
}
有谁知道我怎么做
解决了我所需要做的就是重命名我的字符串
...
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;
}
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.