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

Apps Pass cursor to new activity

Discussion in 'Android Development' started by GabeRC, Sep 30, 2009.

  1. GabeRC

    GabeRC Lurker
    Thread Starter

    Sep 30, 2009
    Hello everyone,

    I'm working on an app, and one activity has a worker thread that initiates a database query, and if there are results once it has returned I would like to send these results to a new activity that will display them. Unfortunately I don't see a way to pack the Cursor object into the Intent object that I am using to start the new activity. When I was doing Windows Mobile development in the past all I would do is edit the constructor for the window to pass in the data, I've searched around but I can't find a similar solution for Android. What is the best way to pass my database results into the new activity?


  2. HUGE

    HUGE Lurker

    Oct 5, 2009
    Perhaps I don't understand the real reason why you want to pass cursor into a new activity, but in general it's a real bad idea. It can be bad in general for complex objects roaming across activities but it's even worse for cursors - you create a cursor based on Context and thus it should not be used outside of this context. So there are two obvious solutions:
    - pass URI rather than Cursor
    - make query() in the same activity which is supposed to display query results

Share This Page