• 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
Sep 30, 2009
1
0
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
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones