/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: Tim Marston
  • Date: 2013-07-19 16:00:10 UTC
  • Revision ID: tim@ed.am-20130719160010-4jxhmuqee2zmzsjn
added a new family pic!

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.Phones.TYPE_MOBILE:
 
61
                        case Contacts.PhonesColumns.TYPE_MOBILE:
62
62
                                return ContactData.TYPE_MOBILE;
63
 
                        case Contacts.Phones.TYPE_FAX_HOME:
 
63
                        case Contacts.PhonesColumns.TYPE_FAX_HOME:
64
64
                                return ContactData.TYPE_FAX_HOME;
65
 
                        case Contacts.Phones.TYPE_FAX_WORK:
 
65
                        case Contacts.PhonesColumns.TYPE_FAX_WORK:
66
66
                                return ContactData.TYPE_FAX_WORK;
67
 
                        case Contacts.Phones.TYPE_PAGER:
 
67
                        case Contacts.PhonesColumns.TYPE_PAGER:
68
68
                                return ContactData.TYPE_PAGER;
69
 
                        case Contacts.Phones.TYPE_WORK:
 
69
                        case Contacts.PhonesColumns.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.Phones.TYPE_WORK:
 
79
                        case Contacts.ContactMethodsColumns.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.managedQuery( Contacts.People.CONTENT_URI,
 
96
                        _cur = _activity.getContentResolver().query(
 
97
                                Contacts.People.CONTENT_URI,
97
98
                                new String[] {
98
99
                                        Contacts.People._ID,
99
100
                                        Contacts.People.NAME,
102
103
                }
103
104
 
104
105
                // if there are no more contacts, abort
105
 
                if( _cur == null || !_cur.moveToNext() ) {
 
106
                if( _cur == null ) return false;
 
107
                if( !_cur.moveToNext() ) {
 
108
                        _cur.close();
106
109
                        _cur = null;
107
110
                        return false;
108
111
                }
115
118
                        _cur.getString( _cur.getColumnIndex( Contacts.People.NAME ) ) );
116
119
 
117
120
                // add notes
118
 
                contact.addNote(
119
 
                        _cur.getString( _cur.getColumnIndex( Contacts.People.NOTES ) ) );
 
121
                String note = _cur.getString(
 
122
                        _cur.getColumnIndex( Contacts.People.NOTES ) );
 
123
                if( note != null && note.length() > 0 )
 
124
                        contact.addNote( note );
120
125
 
121
126
                // add the organisations
122
 
                Cursor cur = _activity.managedQuery( Contacts.Organizations.CONTENT_URI,
 
127
                Cursor cur = _activity.getContentResolver().query(
 
128
                        Contacts.Organizations.CONTENT_URI,
123
129
                        new String[] {
124
130
                                Contacts.Organizations.COMPANY,
125
131
                                Contacts.Organizations.TITLE,
136
142
                cur.close();
137
143
 
138
144
                // add the phone numbers
139
 
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
 
145
                cur = _activity.getContentResolver().query(
 
146
                        Contacts.Phones.CONTENT_URI,
140
147
                        new String[] {
141
148
                                Contacts.Phones.NUMBER,
142
149
                                Contacts.Phones.TYPE,
153
160
                cur.close();
154
161
 
155
162
                // add the email and postal addresses
156
 
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
 
163
                cur = _activity.getContentResolver().query(
 
164
                        Contacts.ContactMethods.CONTENT_URI,
157
165
                        new String[] {
158
166
                                Contacts.ContactMethods.KIND,
159
167
                                Contacts.ContactMethods.TYPE,