Listen to any cursor changes in android

I would like to listen to any changes in the cursor. Is it possible to get it without using contentprovider in android?

Note. (I do not use any data adapter)

thanks

+4
source share
2 answers

I found that you do not need to use a content provider. When data ever changes (e.g., in inserts, deletes, etc.), you can simply call getContentResolver (). notifyChange (Uri uri, ContentObserver observer) and set contentObserver in your activity to listen for changes.

+2
source

As far as I know, if your cursor changes are caused by requery () or some other method on the cursor, such as close (), you can use a dataset observer to track changes.

But you will need a content provider if you want to automatically update when something changes in your data source, for example, your sqlite database. In this case, you can check the information below.

Which cursor are you using?

0
source

Source: https://habr.com/ru/post/1401120/