Class structure for a ContentProvider having multiple sub tables

江枫思渺然 提交于 2019-12-03 22:19:38

If your class supports multiple sub-tables then there must be one CONTENT_URI constant declared for each. How? You can't do that unless you sub-class for each sub-table.

Don't name them all CONTENT_URI, then. That name isn't terribly useful for third parties, anyway, since they won't have access to your source code to access that static data member. The documentation confused me too, and I even kinda parrot their instructions in my one book, but I am moving away from that and will be revamping my materials to match.

A better place to look is their own content providers (ContactsContract, CallLog, etc.).

Do you implement the sub-table providers as descendants? With multiple sub-tables, there is still only ONE ContentProvider class?

Have as many as you want. You can do it with a single class, or with inner classes (see ContactsContract), or whatever.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!