In an Android application, should I have one content provider for each table, or only one for the entire application?

I have many years of experience developing Microsoft.NET (primarily C #), and we are working to speed up work on Android and Java. So far I have created a small application with several screens and a working content provider.

All the examples that I saw for developing content providers usually work with one table, so I got the impression that this was an agreement.

I built some more content providers for other tables and ran into an "Unknown URI" IllegalArgumentException when I tried to test them. The exception is one of my content providers, but not the one I intended to call.

It looks like my application uses the first content provider in the AndroidManifest.xml file, and now I'm wondering if I should have only one content provider for the entire application.

Are there any recommendations and / or examples of working with multiple tables in an Android application? Should I have one content provider for each table, or only one for the entire application? If the first, how do I enable the URI for the appropriate provider? If the latter, how can I make the content provider code get infected with switch statements?

+5
source share
2 answers

99% of Android apps do not need content providers.

: . :

  • , -
  • Android , (, )

.

, , .

, 99%, , , , (, SQLiteDatabase).

+2

, CommonsWare. IllegalStateExceptions , Cursorloader. . . . , . .query URI. , uri .

+10

All Articles