using ContentProviderClient vs ContentResolver to access content provider

前端 未结 5 1772
广开言路
广开言路 2020-12-07 11:09

The documentation on Android content providers describes using a ContentResolver, obtained from getContentResolver(), to access the content.

<
5条回答
  •  忘掉有多难
    2020-12-07 11:16

    I found the following difference: I wrote my own custom contentprovider in app A. I wrote a homescreen Widget in App B. When I tried to access the ContentProvider of app A via a ContentResolver from my widget, I got an "failed to find provider info" error. When I instead would aquire a ContentProviderClient through the ContentResolver and query through the ContentProviderClient, it would work. I had to change nothing else, only use the ContentProviderClient instead of the ContentResolver. I have no real explanation for that behaviour and found no information on the internet, as to why it is like that. I do not know, if this is a special quirk of widgets, because I did not try it from an activity in app B (app B is a mere widget, with no activity).

提交回复
热议问题