what case the managedQuery method return null if uri is provided?
I am doing some android applica开发者_运维技巧tion. I just wonder what will case the managedQuery method return a null value?
if (getIntent().getData() == null) {
getIntent().setData(Notepad.Notes.CONTENT_URI);
}
uri = getIntent().getData();
c = managedQuery(uri, PROJECTION, null, null, null);// return null value.
managedQuery() will return null if any of the following are true:
- The
Urisupplied in the first parameter isnull - The content provider implementation returned null as a result of the query
- If an exception occurred when the content provider attempted to process the query
I really do not like your call to setData(). Please try something like:
Uri uri=getIntent().getData();
if (uri==null) {
uri=Notepad.Notes.CONTENT_URI;
}
c=managedQuery(uri, PROJECTION, null, null, null);
This way, you know your Uri will not be null, so if you get null back from the managedQuery() call, your problem lies in the content provider.
加载中,请稍侯......
精彩评论