/android/export-contacts

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

« back to all changes in this revision

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

  • Committer: edam
  • Date: 2012-12-21 17:49:39 UTC
  • Revision ID: tim@ed.am-20121221174939-rih1gx3m91q8e5gs
removed check for deleted contacts (that seems to be broken); fixed conversion on types for ContactsContract backend

Show diffs side-by-side

added added

removed removed

4
4
 * Copyright (C) 2011 to 2012 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Export 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/export-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
93
93
                if( _cur == null )
94
94
                {
95
95
                        // get all contacts
96
 
                        _cur = _activity.getContentResolver().query(
97
 
                                Contacts.People.CONTENT_URI,
 
96
                        _cur = _activity.managedQuery( Contacts.People.CONTENT_URI,
98
97
                                new String[] {
99
98
                                        Contacts.People._ID,
100
99
                                        Contacts.People.NAME,
103
102
                }
104
103
 
105
104
                // if there are no more contacts, abort
106
 
                if( _cur == null ) return false;
107
 
                if( !_cur.moveToNext() ) {
108
 
                        _cur.close();
 
105
                if( _cur == null || !_cur.moveToNext() ) {
109
106
                        _cur = null;
110
107
                        return false;
111
108
                }
124
121
                        contact.addNote( note );
125
122
 
126
123
                // add the organisations
127
 
                Cursor cur = _activity.getContentResolver().query(
128
 
                        Contacts.Organizations.CONTENT_URI,
 
124
                Cursor cur = _activity.managedQuery( Contacts.Organizations.CONTENT_URI,
129
125
                        new String[] {
130
126
                                Contacts.Organizations.COMPANY,
131
127
                                Contacts.Organizations.TITLE,
142
138
                cur.close();
143
139
 
144
140
                // add the phone numbers
145
 
                cur = _activity.getContentResolver().query(
146
 
                        Contacts.Phones.CONTENT_URI,
 
141
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
147
142
                        new String[] {
148
143
                                Contacts.Phones.NUMBER,
149
144
                                Contacts.Phones.TYPE,
160
155
                cur.close();
161
156
 
162
157
                // add the email and postal addresses
163
 
                cur = _activity.getContentResolver().query(
164
 
                        Contacts.ContactMethods.CONTENT_URI,
 
158
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
165
159
                        new String[] {
166
160
                                Contacts.ContactMethods.KIND,
167
161
                                Contacts.ContactMethods.TYPE,