[android-developers] Re: Listening to changes in address book

2009-02-03 Thread Shrikant Agrawal

Thanks Mark

But is there any way to know what fields are changed.


On Feb 3, 10:08 pm, Mark Roberts snappe...@gmail.com wrote:
 You can register an observer to monitor a specific uri.  For example:

 Define the observer
 private ContentObserver yourObserver = new ContentObserver(new Handler
 ()) {
         @Override
         public boolean deliverSelfNotifications() {
             return true;
         }

         @Override
         public void onChange(boolean selfChange) {
             Cursor cursor = getCursor();
             if (cursor != null  !cursor.isClosed()) {
                 cursor.requery();
             }
         }
     };

 Now add the code to register it.
 getContentResolver().registerContentObserver(Uri.parse(content://
 contacts/people),
                     true, yourObserver);

 This will notify you whenever a change is made to the people table.
 It will not however tell you what was changed.

 On Feb 3, 11:40 am, Shrikant Agrawal shrikant...@gmail.com wrote:

  Hi

  Is there any way to know the changes made in the address book.
  What I want to know is that whenever an contact is added ,modified or
  deleted  my app should receive the notification as well as the ID of
  the contact changed.

  Thanks in advance
  Shrikant
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[android-developers] Re: Listening to changes in address book

2009-02-03 Thread Mark Roberts

I do not believe so.

The above code just redraws the screen anytime there is a change to
the people table.

On Feb 3, 1:07 pm, Shrikant Agrawal shrikant...@gmail.com wrote:
 Thanks Mark

 But is there any way to know what fields are changed.

 On Feb 3, 10:08 pm, Mark Roberts snappe...@gmail.com wrote:

  You can register an observer to monitor a specific uri.  For example:

  Define the observer
  private ContentObserver yourObserver = new ContentObserver(new Handler
  ()) {
          @Override
          public boolean deliverSelfNotifications() {
              return true;
          }

          @Override
          public void onChange(boolean selfChange) {
              Cursor cursor = getCursor();
              if (cursor != null  !cursor.isClosed()) {
                  cursor.requery();
              }
          }
      };

  Now add the code to register it.
  getContentResolver().registerContentObserver(Uri.parse(content://
  contacts/people),
                      true, yourObserver);

  This will notify you whenever a change is made to the people table.
  It will not however tell you what was changed.

  On Feb 3, 11:40 am, Shrikant Agrawal shrikant...@gmail.com wrote:

   Hi

   Is there any way to know the changes made in the address book.
   What I want to know is that whenever an contact is added ,modified or
   deleted  my app should receive the notification as well as the ID of
   the contact changed.

   Thanks in advance
   Shrikant
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---