And now for a more direct answer to your immediate question: yes, you
are right. The Handler is for passing a message to the thread on which
it (the Handler) was created. But that is precisely what a
ContentProvider needs for receiving a message telling it that the
relevant database view has been updated.

That is what the verbage at the link you gave means, when it says,
"This method [onChange] is called when a change occurs to the cursor
that is being observed."

Now just in case that was too brief and quick, let me connect all the
dots:

1) as you observed, the constructor ContentProvider(Handler) takes a
handler. The comment says, "The handler to run onChange(boolean) on. "
2) but this onChange is the one I mentioned above: ContentProvider has
to know which handler to use, so it takes that info in the constructor
argument
3) the mysterious 'cursor' is a database notion. It is roughly
analogous to the cursor on your computer screen, keeping track not of
LCD display but of the current read position in the database. So when
they say, "cursor that is being observed", they are referring to
database changes.
4) Obviously if the ContentProvider is to work at all, it needs to
know about database changes, even if it is just just the current read
position (cursor) that has changed.

This will all seem SO much more clear when you see it in the Notepad
example code.

On Oct 12, 10:07 am, Dinesh Bajaj <dinesh.bajaj...@gmail.com> wrote:
> Hi,
>
> I have read the Android doc on the 
> ContentObserver<http://developer.android.com/reference/android/database/ContentObserv...>class,
>  but am not able to understand what is its use? What will be the
> difference if null instead is passed to the constructor?
>
> My understanding is that a Handler object is used to pass a message to the
> thread on which it is created, but I can't understand its use in the context
> of passing it to the ContentObserver.
>
> I would be grateful if someone could throw light on this.
>
> Thanks,
> Dinesh

-- 
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

Reply via email to