Reputation: 6385
I have a list view that could be potentially large (10k+ items). When the user clicks on an item in the list, I take an action in a Service which needs the cursor for access to the entire list. Since I cant pass the cursor through an Intent from the activity I just send the id of the selected item to the Service then requery the database based off of this id. However, since this is a complex query with a lot of data, it can potentially take a while. Would it be faster to have this cursor in a Parseable class instead of requerying the database? I can then pass the parseable class in an Intent to the Activity.
Thanks
Upvotes: 1
Views: 803
Reputation: 1271
You can use a cursor window to parcel data from a cursor.If you are not doing any write operations:
CursorWindow window = new CursorWindow("MY_CURSOR_WINDOW");
cursor.fillWindow(0, window);
intent.putExtra(String name, window);
In case you want to do write operation then you need to query and get a cursor,since cursorwindow caches the data and nothing else much.
Cheers.
Upvotes: 1