• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Pass cursor to new activity

GabeRC

Lurker
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?
 
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
 
Back
Top Bottom