Cursormanagement in Service-Class

Put your problem here if it does not fit any of the other categories.

Cursormanagement in Service-Class

Postby sem_thesis » Sun Apr 03, 2011 12:30 pm

Hello there! :D

I'm currently working on a Service, which extracts all information from the Contacts app (e.g. name, number, email, etc).
Now, I've been searching a while and the best tutorial I came across is the following: http://blog.app-solut.com/2011/03/working-with-the-contactscontract-to-query-contacts-in-android/

The basic idea is to use a Contact-Provider, as only they can give you access to content information of another app.

Now, to access a contact-Provider you 1) first need the CONTENT_URI and then 2) need to create a cursor to access content.
The Cursor is created via the 'managedQuery(...) - Method', whch is only given for Activities. However, I'm implementing a service, so using managedQuery results in an error shown by Eclipse.


So, my question is: Is there any alternative to creating cursors rather than with the managedQeury method?


Open for all comments and suggestions :)
sem_thesis
Freshman
Freshman
 
Posts: 9
Joined: Sun Mar 06, 2011 12:29 pm

Top

Re: Cursormanagement in Service-Class

Postby sem_thesis » Tue Apr 05, 2011 6:51 pm

Found the solution myself:

Use 'getContentResolver().query(...)' instead of 'managedQuery()' and don't forget to close the cursor after the query.
sem_thesis
Freshman
Freshman
 
Posts: 9
Joined: Sun Mar 06, 2011 12:29 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 23 guests