如何获得插入行的URI在我的内容观察员? [英] How to get URI of inserted row in my content observer?

查看:143
本文介绍了如何获得插入行的URI在我的内容观察员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我从一个不同的类,它给了我插入的行ID插入数据库中的值。 我已经注册了它的观察员在我的UI和当任何行插入,我的UI内容的观察者会被调用。 这两个类是完全不同的,所以我发现它来获取插入难行ID。 有没有什么办法让此行的ID在我的内容观察,这样我可以相应地更新我的UI?

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 row is inserted, my UI content observer will get called. Both the classes are entirely different so I am finding it difficult to get inserted row id. Is there any way to get this row id in my content observer so that I can update my UI accordingly?

P.S。 context.getContentResolver()有NotifyChange(URI,空)。是不是我的解决方案,因为我想实现的(更新影响的变化)的用户界面。

P.S. context.getContentResolver().notifyChange(uri, null); is not my solution, as i want effected in ( to update effected change ) on UI .

推荐答案

在插入新行,你必须手动调用<一href="http://developer.android.com/reference/android/content/ContentResolver.html#notifyChange%28android.net.Uri,%20android.database.ContentObserver%29"相对=nofollow>有NotifyChange :

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

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

在code表示插入的行应该有机会获得新的rowid,并应能构建URI传递给有NotifyChange。当通知更改被调用时,它应该引起所有 ContentObservers 更新。

这篇关于如何获得插入行的URI在我的内容观察员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆