Update all the contacts belonging to one group

by cyril.at...@gmail.com » Mon, 28 Sep 2009 19:58:51 GMT


Sponsored Links
 Dear all,

I have an application that updates all the contacts belonging to a
group, I currently do the following :
-> Get the group id
-> Get all the contacts id inside this group
-> For each of them I am doing an update on the contact => This is
really heavy and seems to take time in real phones while I expect it
to be "instantaneous".

I am wondering if we can, in the ContentResolver.update() method
specify a kind of join.
For instance I'd like to do something like :
UPDATE <people> SET <people.name>="<new name>" FROM People p,
GroupsMemberships gm WHERE p.person_id=gm.person_id and
gm.group_id=<my_group_id>

Does anyone know if it's possible or not?

The update method has got a "where" attribut but can we use this
attribut for complexe requests ?
*****
where   A filter to apply to rows before deleting, formatted as an SQL
WHERE clause (excluding the WHERE itself).
***********

Thanks to everyone for its feedback.
--~--~---------~--~----~------------~-------~--~----~



Update all the contacts belonging to one group

by Mark Murphy » Mon, 28 Sep 2009 20:20:36 GMT


 


Not that I am aware of. Bear in mind that not all content providers will
be using a SQL database as the place of data storage.

Since the contacts content provider does appear to use SQLite, rather
than iterating over your contacts, though, you could try the IN syntax
in the WHERE-style constraint:

[WHERE] person_id IN (...)

where ... is a comma-delimited set of values, or possibly even a
sub-select to get the IDs of the contacts to update.

 http://sqlite.org/lang_expr.html 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Looking for Android opportunities?  http://wiki.andmob.org/hado 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Update all the contacts belonging to one group

by 6real » Wed, 30 Sep 2009 04:02:50 GMT


 Dear Mark,

your solution sounds really great but I discovered that it is just ...
impossible to make some bulk operation on contacts (at least until
release r3).

I then optimized my code to update just what has to be updated.

Thanks you by the way for your answer.

C.





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Do static variables of an ApplicationContext subclass left untouched when the process is killed?

Do static variables of an ApplicationContext subclass left untouched
when the process is killed?

-- 

2. How to check if a user defined service is already running

Dear Folks,
I have a service that is running within the context of my application. It
gets invoked at the start of the activity and then gets update when new data
is inserted or deleted from the database. The problem is that everytime I
start the activity , it restarts the service. As you may have guessed  - not
a very intuitive design. Therefore I was wondering if there is a way to
determine if the service is already running before starting it. I know I can
bind to the service but I do not want that since the main activity needs to
exits after the database operation is completed.

I know for system services, you can get the service details from the
application context. How do you do it for user defined service?

thanks for all help here.

regards
Sunny.

-- 

3. ListView issue (Editors?)

4. multiple instances of media player

5. PV Opencore call chain

6. Crash on gesture recognize

7. Smoothing out a line on a canvas.