/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: 2014-03-02 11:00:38 UTC
  • Revision ID: tim@ed.am-20140302110038-2ojg0b3pfi8vqasq
add permission to read from sdcard (how did this ever work!?)

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.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
                }
121
124
                        contact.addNote( note );
122
125
 
123
126
                // add the organisations
124
 
                Cursor cur = _activity.managedQuery( Contacts.Organizations.CONTENT_URI,
 
127
                Cursor cur = _activity.getContentResolver().query(
 
128
                        Contacts.Organizations.CONTENT_URI,
125
129
                        new String[] {
126
130
                                Contacts.Organizations.COMPANY,
127
131
                                Contacts.Organizations.TITLE,
138
142
                cur.close();
139
143
 
140
144
                // add the phone numbers
141
 
                cur = _activity.managedQuery( Contacts.Phones.CONTENT_URI,
 
145
                cur = _activity.getContentResolver().query(
 
146
                        Contacts.Phones.CONTENT_URI,
142
147
                        new String[] {
143
148
                                Contacts.Phones.NUMBER,
144
149
                                Contacts.Phones.TYPE,
155
160
                cur.close();
156
161
 
157
162
                // add the email and postal addresses
158
 
                cur = _activity.managedQuery( Contacts.ContactMethods.CONTENT_URI,
 
163
                cur = _activity.getContentResolver().query(
 
164
                        Contacts.ContactMethods.CONTENT_URI,
159
165
                        new String[] {
160
166
                                Contacts.ContactMethods.KIND,
161
167
                                Contacts.ContactMethods.TYPE,