开发者

content provider public fields access

A content provider is expected, according to various documentation like http://developer.android.com/guide/topics/providers/content-providers.html, to define final Strings for the URI name and the column names, so that client can access them. This suggests that clients have direct access to t开发者_开发问答he class public fields. But a class can not directly access classes in other apks. How can I write a custom content provider accessible from classes in other apks and how can the clients get the URI and column names ?


You can provide a library with your content provider, which will be included into other apks as jar.


Just small advice:

  • You do not need to share full source code. You should separate your interface from the implementation.
  • So, constants describing URI and column names should be in one Class. Actual implementation in the other class.
  • When sharing your provider via .jar, it is enough to include interface class.
  • While your interface is stable (not changing), you can still improve your implementation and fix the bugs, without need to update it each time to other projects using that content provider.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜