noloman
noloman

Reputation: 11975

Android: Content provider access in a service

I am creating an application that is supposed to start a service which should access to a content provider in android and send some data to an external server.

When accessing the content provider, I need to use the managedQuery function, which has to be called in an Activity. How should I address this issue?

I don't know whether to create another Activity class in order to write the Content Provider access method here. How should I send the data to the server, from the Service itself?

Not sure if I explained myself clearly..

Thanks a lot in advance!

Upvotes: 0

Views: 3565

Answers (1)

kriz
kriz

Reputation: 611

I think you need the ContentResolver class:

ContentResolver cr = getContentResolver();
Cursor c = cr.query(uri, projection, selection, selectionArgs, sortOrder);

// do something

c.close();

Upvotes: 2

Related Questions