Listen to any changes in a cursor in android

旧时模样 提交于 2019-12-01 05:23:43

I found that You don't need to use content Provider.When ever the data changes(like during insertions,deletions etc..) you can just call getContentResolver().notifyChange(Uri uri, ContentObserver observer) and set a contentObserver in your activity to listen for the change.

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

But you will need a content provider, if you want to be updated automatically when something changes in your data source, eg your sqlite database. In that case, you can check the info posted below.

What cursor are you using?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!