1. Check out our companion app, Forums for Android! Download from Google Play

Pass cursor to new activity

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

  1. GabeRC

    GabeRC New Member
    Thread Starter
    5

    Sep 30, 2009
    1
    0
    5
    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?
     

    Advertisement

  2. HUGE

    HUGE New Member
    5

    Oct 5, 2009
    4
    0
    5
    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

Loading...