Search code examples
androiddatabasesqliteandroid-contentproviderreload

Content Resolver SQLite refresh data after operation


My problem is that I do content resolver operations (CRUD) and my local Sqlite data base gets the changes but they do not show/refresh those changes in my TEXTVIEW, in here I'm not talking about refreshing a listview/recyclerview with adapters like 100% of the questions in here I'm just talking about a simple text view which fetch information from the local database so in here I'm not using adapters or recycler views (not yet). I've tried:

  • Use the database helper constructor after a new content resolver operation but is not working.

  • use the close() after a content provider operation.

  • cResolver.notifyChange() after applying a batch of operations.

  • I've tried to use the LoaderManager but it appears that is only useful for adapters with the swapcursor.

How do I know my CRUD ops are working? if I restart my app the changes are there. Any help in the rigth directions will be appreciated thanks.


Solution

  • Any change on your database is reflected only on your database. If you need to update a text view after the change, you need to handle that the change have been made and update your view. An alternative to update your view and data after persisting it to a database is using the LiveData or any observable.