1. Download our Official Android App: Forums for Android!

Apps Cursormanagement in Service-Class

Discussion in 'Android Development' started by sem_thesis, Apr 3, 2011.

  1. sem_thesis

    sem_thesis Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Apr 3, 2011

    Apr 3, 2011
    3
    0
    5
    Hello there! [​IMG]

    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: Working with the ?ContactsContract? to query contacts in Android APP-SOLUT APPLICATION-SOLUTIONS | The Android and iPhone Developer, Tutorial and App News Blog

    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 [​IMG]
     

    Advertisement

  2. sem_thesis

    sem_thesis Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Apr 3, 2011

    Apr 3, 2011
    3
    0
    5
    Ok.. i figured it out.
    Just use:
    getContentResolver().query()
    and don't forget to close the cursor with
    cursorname.close().

    Voil
     

Share This Page

Loading...