- @Override
- public synchronized void onPerformSync(
- Account account,
- Bundle extras,
- String authority,
- ContentProviderClient provider,
- SyncResult syncResult) {
-
- this.setAccount(account);
- this.setContentProvider(provider);
+ @Override
+ public void onPerformSync(Account account, Bundle extras, String authority,
+ ContentProviderClient provider, SyncResult syncResult) {
+ setAccount(account);
+ setContentProvider(provider);
+ Cursor c = getLocalContacts(false);
+ if (c.moveToFirst()) {
+ do {
+ String lookup = c.getString(c
+ .getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
+ String a = getAddressBookUri();
+ String uri = a + lookup + ".vcf";
+ FileInputStream f;
+ try {
+ f = getContactVcard(lookup);
+ HttpPut query = new HttpPut(uri);
+ byte[] b = new byte[f.available()];
+ f.read(b);
+ query.setEntity(new ByteArrayEntity(b));
+ HttpResponse response = fireRawRequest(query);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ } catch (OperationCanceledException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (AuthenticatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } while (c.moveToNext());
+ // } while (c.moveToNext());
+ }