/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: Tim Marston
  • Date: 2014-03-02 10:58:35 UTC
  • Revision ID: tim@ed.am-20140302105835-szgzmrvr7pa5kljw
updated NEWS

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * ContactsBackend.java
3
3
 *
4
 
 * Copyright (C) 2012 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2012 to 2013 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.managedQuery( Contacts.People.CONTENT_URI,
 
61
                cur = _activity.getContentResolver().query(
 
62
                        Contacts.People.CONTENT_URI,
62
63
                        new String[] {
63
64
                                Contacts.People._ID,
64
65
                                Contacts.People.NAME,
96
97
                                        notes.put( id, note );
97
98
                        }
98
99
                }
 
100
                cur.close();
99
101
 
100
102
                // get contact organisations, primary ones first
101
 
                cur = _activity.managedQuery( Contacts.Organizations.CONTENT_URI,
 
103
                cur = _activity.getContentResolver().query(
 
104
                        Contacts.Organizations.CONTENT_URI,
102
105
                        new String[] {
103
106
                                Contacts.Phones.PERSON_ID,
104
107
                                Contacts.Organizations.COMPANY,
124
127
                        // add associated data
125
128
                        cache.addAssociatedOrganisation( id, organisation );
126
129
                }
 
130
                cur.close();
127
131
 
128
132
                // get all phone numbers, primary ones first
129
 
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
 
133
                cur = _activity.getContentResolver().query(
 
134
                        Contacts.Phones.CONTENT_URI,
130
135
                        new String[] {
131
136
                                Contacts.Phones.PERSON_ID,
132
137
                                Contacts.Phones.NUMBER,
152
157
                        // add associated data
153
158
                        cache.addAssociatedNumber( id, number );
154
159
                }
 
160
                cur.close();
155
161
 
156
162
                // now get all email addresses, primary ones first, and postal addresses
157
 
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
 
163
                cur = _activity.getContentResolver().query(
 
164
                        Contacts.ContactMethods.CONTENT_URI,
158
165
                        new String[] {
159
166
                                Contacts.ContactMethods.PERSON_ID,
160
167
                                Contacts.ContactMethods.DATA,
198
205
                                cache.addAssociatedAddress( id, address );
199
206
                        }
200
207
                }
 
208
                cur.close();
201
209
 
202
210
                // finally, add the notes that we stored earlier (we have to add these
203
211
                // at the end because we can't be sure which piece of contact data will
363
371
                        values, null, null );
364
372
        }
365
373
 
 
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
        }
366
380
}