Use AsyncTask to update the contacts .

Nithin


On Mar 29, 2:56 pm, cpphool <cpph...@gmail.com> wrote:
> thank you for your response!
>
> Unfortunately this method took even longer - 31sec on Magic.
>
> On 23 Mar, 15:50, timo prill <timo.pr...@googlemail.com> wrote:
>
> > hey,
>
> > try this. maybe its a faster approach to go directly through the
> > ContentResolver instead of using createPersonInMyContactsGroup:
>
> >        ContentValues values = new ContentValues();
> >        Uri uri;
> >        String id;
> >        ContentResolver cr = getContentResolver ();
> >        for (int i = 0; i < 100; i++) {
> >             values.clear();
> >             values.put(People.NAME, "Test" + i);
> >             uri = cr.insert(People.CONTENT_URI, values);
> >             id = uri.getLastPathSegment();
> >             People.addToMyContactsGroup(cr, Long.parseLong(id));
> >        }
>
> > cheers.
>
> > cpphool schrieb:
>
> > > Hi!
>
> > > Currently, I'm using HTC Magic (1.5) and Acer Liquid (1.6) to test the
> > > app.
>
> > > my sample code snippet for API < 2.0:
>
> > > for (int i = 0; i < 100; i++) {
> > > Log.d(TAG,"iteracja " + i);
> > > ContentValues personValues = new ContentValues();
> > > personValues.put(Contacts.People.NAME, "Test" + i);
> > > personValues.put(Contacts.People.STARRED, 0);
> > > Uri newPersonUri =
> > > Contacts.People.createPersonInMyContactsGroup(getContentResolver(),
> > > personValues);
> > > }
>
> > > I did a few tests. Each time I changed NAME String in order to avoid
> > > duplicates.
>
> > > Results:
> > > 1) Acer Liquid (sync off) - 12 sec
> > > 2) Acer Liquid (sync on) - 30 sec
> > > 3) Acer Liquid (sync on) - 55 sec
> > > 4) Acer Liquid (sync on) - 35 sec
> > > 5) Acer Liquid (sync off) - 13 sec
>
> > > 1) HTC Magic (sync off) - 27 sec
> > > 2) HTC Magic (sync off) - stuck. log from logcat:
>
> > > ERROR/CursorWindow(13459): need to grow: mSize = 1048576, size = 279,
> > > freeSpace() = 162, numRows = 2789
> > > ERROR/CursorWindow(13459): not growing since there are already 2789
> > > row(s), max size 1048576
> > > ERROR/CursorWindow(13459): The row failed, so back out the new row
> > > accounting from allocRowSlot 2788
> > > ERROR/Cursor(13459): Failed allocating fieldDir at startPos 0 row 2788
> > > DEBUG/Cursor(13459): finish_program_and_get_row_count row 2213
>
> > > then I turned the sync off and my application started running again
> > > (without restarting the app)! took 30 sec to complete.
>
> > > Even if we turn off sync on HTC Magic it takes a long time to simply
> > > add empty contacts. Adding 5000 empty contacts (without any other
> > > operations) would take 1500sec = 25min.
>
> > > On 23 Mar, 11:55, timo prill <timo.pr...@googlemail.com> wrote:
> > >> hi,
>
> > >> which SDK version are you using? 1.5? 1.6? 2.0? 2.1?
> > >> there were some changes to the contact api from 1.6 to 2.0...
>
> > >> and maybe give a short snippet of how you insert the contacts to the
> > >> database.
> > >> maybe you do some (wrong) very time-consuming database-queries or you
> > >> just missed something, because i have seen my code using the contact db
> > >> implementation run way faster.. even with vcard-parsing & full blown
> > >> contacts...on the htc magic
>
> > >> cheers
>
> > >> cpphool schrieb:
>
> > >>> Hi!
> > >>> I have some questions concerning importing contacts to the device,
> > >>> which is extremely slow.
> > >>> First of all, if you delete all your contacts, google sync will
> > >>> restore it very quickly. However, when my app is adding contacts to
> > >>> the device, it's very slow (a few contacts per second). Even if I add
> > >>> almost empty contacts (with name only), it is a time-consuming
> > >>> process.
> > >>> If I turn google sync off, importing 5000 contacts can take 1-2 hours
> > >>> (on HTC Magic). When google sync is on it can take up to 24hours. And
> > >>> this happens despite the fact, that application for the whole time is
> > >>> in the foreground, device is connected to charger and screen is on. I
> > >>> checked the logcat to make sure my app is adding the contacts the
> > >>> whole time, and it is.
> > >>> I tried different methods and different devices. The results differ of
> > >>> course, yet manually adding contacts is always significantly slower
> > >>> that google sync. Is there any way that I can speed up the process? So
> > >>> that importing 5000 contacts will take less than an hour.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to