/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 13:28:27 UTC
  • Revision ID: tim@ed.am-20121221132827-u32vfk3ywktt7xa5
updated some copyright dates

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
58
58
                {
59
59
                        switch( type )
60
60
                        {
61
 
                        case Contacts.PhonesColumns.TYPE_MOBILE:
 
61
                        case Contacts.Phones.TYPE_MOBILE:
62
62
                                return ContactData.TYPE_MOBILE;
63
 
                        case Contacts.PhonesColumns.TYPE_FAX_HOME:
 
63
                        case Contacts.Phones.TYPE_FAX_HOME:
64
64
                                return ContactData.TYPE_FAX_HOME;
65
 
                        case Contacts.PhonesColumns.TYPE_FAX_WORK:
 
65
                        case Contacts.Phones.TYPE_FAX_WORK:
66
66
                                return ContactData.TYPE_FAX_WORK;
67
 
                        case Contacts.PhonesColumns.TYPE_PAGER:
 
67
                        case Contacts.Phones.TYPE_PAGER:
68
68
                                return ContactData.TYPE_PAGER;
69
 
                        case Contacts.PhonesColumns.TYPE_WORK:
 
69
                        case Contacts.Phones.TYPE_WORK:
70
70
                                return ContactData.TYPE_WORK;
71
71
                        default:
72
72
                                return ContactData.TYPE_HOME;
76
76
                {
77
77
                        switch( type )
78
78
                        {
79
 
                        case Contacts.ContactMethodsColumns.TYPE_WORK:
 
79
                        case Contacts.Phones.TYPE_WORK:
80
80
                                return ContactData.TYPE_WORK;
81
81
                        default:
82
82
                                return ContactData.TYPE_HOME;
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
                }
118
115
                        _cur.getString( _cur.getColumnIndex( Contacts.People.NAME ) ) );
119
116
 
120
117
                // add notes
121
 
                String note = _cur.getString(
122
 
                        _cur.getColumnIndex( Contacts.People.NOTES ) );
123
 
                if( note != null && note.length() > 0 )
124
 
                        contact.addNote( note );
 
118
                contact.addNote(
 
119
                        _cur.getString( _cur.getColumnIndex( Contacts.People.NOTES ) ) );
125
120
 
126
121
                // add the organisations
127
 
                Cursor cur = _activity.getContentResolver().query(
128
 
                        Contacts.Organizations.CONTENT_URI,
 
122
                Cursor cur = _activity.managedQuery( Contacts.Organizations.CONTENT_URI,
129
123
                        new String[] {
130
124
                                Contacts.Organizations.COMPANY,
131
125
                                Contacts.Organizations.TITLE,
142
136
                cur.close();
143
137
 
144
138
                // add the phone numbers
145
 
                cur = _activity.getContentResolver().query(
146
 
                        Contacts.Phones.CONTENT_URI,
 
139
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
147
140
                        new String[] {
148
141
                                Contacts.Phones.NUMBER,
149
142
                                Contacts.Phones.TYPE,
160
153
                cur.close();
161
154
 
162
155
                // add the email and postal addresses
163
 
                cur = _activity.getContentResolver().query(
164
 
                        Contacts.ContactMethods.CONTENT_URI,
 
156
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
165
157
                        new String[] {
166
158
                                Contacts.ContactMethods.KIND,
167
159
                                Contacts.ContactMethods.TYPE,