Nouman Ghaffar
Nouman Ghaffar

Reputation: 137

Android get multiple content Provider with single cursor

Hello Everyone , I am creating an application in which I have to deal with multiple content providers. To get every content I have to create a cursor. For example I create a cursor to get phone contacts and then create another to get call logs etc.I wonder is this necessary to create a new cursor every time to get a content.I want to know is there any way to get multiple contents with single cursor so that my code will be shorten. Thanks in advance

Upvotes: 0

Views: 124

Answers (1)

Christopher Francisco
Christopher Francisco

Reputation: 16268

It is not possible, and even if it was, that's not the way to go. Imagine you got a Database with multiple tables: customers, sales, products; and each time you ask for customers, it brings you sales and products too. Not so efficient, right?

The correct way to go is use 1 Cursor for each data set you need.

PS: also always remember that shorter code != better. Easy maintainable code == better. That is called Scalability. Read more here.

Upvotes: 1

Related Questions