Saturday, December 3, 2011

[android-developers] ContentResolver.query() get null cursor

Hi All,

I have an application to read the Android contacts, and I use
ContentResolver.query() to query the data.
Sometimes, I get the required data, but on other times, I get a null
cursor. For example,

context.getContentResolver().query(Contacts.CONTENT_URI, projection,
Contacts.IN_VISIBLE_GROUP + "=?", new String[]
{ "1" }, null);

This inconsistency makes me big trouble. Of course, I can check the
cursor is null or not before I use it, but does it make sense even if
I knew it was null, query again? What I need is the right result.

My question is the null cursor is normal? Or my use of the content
provider has something wrong?
Any help will highly appreciated!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment