开发者

what case the managedQuery method return null if uri is provided?

开发者 https://www.devze.com 2023-01-04 21:25 出处:网络
I am doing some android applica开发者_运维技巧tion. I just wonder what will case the managedQuery method return a null value?

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 Uri supplied in the first parameter is null
  • 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消