/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/ContactsBackend.java

  • Committer: edam
  • Date: 2012-12-30 17:17:51 UTC
  • Revision ID: tim@ed.am-20121230171751-8ni3r9bf7pqpa2ng
less strict parsing of vcard begin/end lines and version numbers

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * ContactsBackend.java
3
3
 *
4
 
 * Copyright (C) 2012 to 2013 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2012 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Import Contacts program (hereafter referred
7
 
 * to as "this program").  For more information, see
 
7
 * to as "this program"). For more information, see
8
8
 * http://ed.am/dev/android/import-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
58
58
                HashMap< Long, String > notes = new HashMap< Long, String >();
59
59
 
60
60
                // get all contacts
61
 
                cur = _activity.getContentResolver().query(
62
 
                        Contacts.People.CONTENT_URI,
 
61
                cur = _activity.managedQuery( Contacts.People.CONTENT_URI,
63
62
                        new String[] {
64
63
                                Contacts.People._ID,
65
64
                                Contacts.People.NAME,
97
96
                                        notes.put( id, note );
98
97
                        }
99
98
                }
100
 
                cur.close();
101
99
 
102
100
                // get contact organisations, primary ones first
103
 
                cur = _activity.getContentResolver().query(
104
 
                        Contacts.Organizations.CONTENT_URI,
 
101
                cur = _activity.managedQuery( Contacts.Organizations.CONTENT_URI,
105
102
                        new String[] {
106
103
                                Contacts.Phones.PERSON_ID,
107
104
                                Contacts.Organizations.COMPANY,
127
124
                        // add associated data
128
125
                        cache.addAssociatedOrganisation( id, organisation );
129
126
                }
130
 
                cur.close();
131
127
 
132
128
                // get all phone numbers, primary ones first
133
 
                cur = _activity.getContentResolver().query(
134
 
                        Contacts.Phones.CONTENT_URI,
 
129
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
135
130
                        new String[] {
136
131
                                Contacts.Phones.PERSON_ID,
137
132
                                Contacts.Phones.NUMBER,
157
152
                        // add associated data
158
153
                        cache.addAssociatedNumber( id, number );
159
154
                }
160
 
                cur.close();
161
155
 
162
156
                // now get all email addresses, primary ones first, and postal addresses
163
 
                cur = _activity.getContentResolver().query(
164
 
                        Contacts.ContactMethods.CONTENT_URI,
 
157
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
165
158
                        new String[] {
166
159
                                Contacts.ContactMethods.PERSON_ID,
167
160
                                Contacts.ContactMethods.DATA,
205
198
                                cache.addAssociatedAddress( id, address );
206
199
                        }
207
200
                }
208
 
                cur.close();
209
201
 
210
202
                // finally, add the notes that we stored earlier (we have to add these
211
203
                // at the end because we can't be sure which piece of contact data will
371
363
                        values, null, null );
372
364
        }
373
365
 
374
 
        @Override
375
 
        public void addContactBirthday( Long id, String birthday )
376
 
                throws ContactCreationException
377
 
        {
378
 
                // this contacts API doesn't support birthdays, so just ignore them
379
 
        }
380
366
}