How to get URI of inserted row in my content observer?

前端 未结 2 1473
被撕碎了的回忆
被撕碎了的回忆 2020-12-21 07:18

In my application, I am inserting values in database from a different class which gives me id of inserted row. I have registered an observer of it in my UI and whenever any

2条回答
  •  不思量自难忘°
    2020-12-21 07:38

    When you insert the new row, you have to manually call notifyChange:

    context.getContentResolver().notifyChange(uri, null);
    

    The code that inserted the row should have access to the new rowid, and should be able to construct the URI to pass to notifyChange. When notify change is called, it should cause all ContentObservers to be updated.

提交回复
热议问题