1. HUGE Androidforums.com UPDATE! Learn what's new (and download the new app!)
    Dismiss Notice

Pass cursor to new activity

Last Updated:

  1. GabeRC

    GabeRC New Member This Topic's Starter

    Sep 30, 2009
    Likes Received:
    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 New Member

    Oct 5, 2009
    Likes Received:
    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