0

Currently I'm receiving a JSON from a server with updated information on a contact. Currently, I iterate through the JSON and do an update on my app on the phone, but for 2000 contacts, it takes up to 50 seconds(I used transactions too, b4 that it took 70 seconds). Is there a faster way to speed this up?

Maurice
  • 6,413
  • 13
  • 51
  • 76
  • Could you show us how you use the transactions? Because I expected a bigger speed up using it than from 70 seconds to 50 seconds. See my answer here: http://stackoverflow.com/questions/3501516/android-sqlite-database-slow-insertion/3501572#3501572 – WarrenFaith Sep 14 '11 at 13:35

3 Answers3

1

Well, just remember that it's 2,000 row updates, and on a handheld phone/tablet. It's not a high-powered server with an in-memory database. This stuff takes time. Unless you're doing something more than what you're saying, it doesn't sound like you're taking more steps than required (i.e. there's nothing to cut out in order to save time)

Often performance is just as much perception, as it is optimization. One way to deal with this reality is to simply return control of the UI to the user, making your app look snappy and responsive, while doing the contact updates in another thread in the background. That would give your app the appearance of being very fast, even though it still takes 50 seconds to complete all the updates.

jefflunt
  • 33,527
  • 7
  • 88
  • 126
  • Thanks for the advice. I tried on another phone it's really much faster! – Maurice Sep 14 '11 at 02:18
  • There you go - probably hardware constraints for the most part, or some other factor in the specific build of the OS that you're using - i.e. something outside the scope of your app itself, in this case. – jefflunt Sep 14 '11 at 02:22
1

Are you using Android's built-in JSON objects? If so, that may be the source of the performance problem. The first time I profiled my app, I was surprised to find that JSON parsing was causing the biggest performance hit (see also this post in the Android Developers Blog).

Nick Bradbury
  • 1,745
  • 13
  • 14
1

You should profile your code to find exactly what is taking the most processing power then perhaps you may be able to find a more efficient solution to your problem

Profiling on Android is done making a tracefile on view, then viewing it with Traceview.

See here for detailed information

Kurru
  • 14,180
  • 18
  • 64
  • 84