Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Content Provider or Multiple Content Providers in Android?

I am kind of stuck in dilemma, I am making an application which consist of multiple tables/entities and I am using Content Provider to manage my sql data. Almost every table in db has a relation with other table.

Now I am really confused whether I should make a single content provider, stuff it with 9,10 tables and use it. Or should I make a separate content provider for every single table and use it.

I can handle join queries between tables in both ways as well. Can anyone give me pros and cons for both approaches? and guide me in the right direction ?

Any kind of help, would be highly appreciated.

like image 578
ShahrozKhan91 Avatar asked Dec 14 '25 01:12

ShahrozKhan91


1 Answers

If the tables relate to each other and presumably you would like to do joins then you should do one content provider and not multiple. I assume if the tables relate then you will be wanting to do joins on data or at the very least enforce foreign key constraints.

Also for doing joins the best way. In my opinion to do them is to create a view. Treat it kinda like a table. You can query it like a table also. Just my advice. If your still interested in this I can go into more detail.

like image 127
startoftext Avatar answered Dec 15 '25 18:12

startoftext



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!