/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-21 21:05:13 UTC
  • Revision ID: tim@ed.am-20121221210513-scyf50006hqadgjw
updated NEWS

Show diffs side-by-side

added added

removed removed

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