How Can I Pass Cursor To Another Activity?
I need to pass Cursor object to another activity, what is the best way to do it?
Solution 1:
You can share you Cursor object using Application class, but it is not entertain because it is recommended not to use static reference much, So its Better to create cursor with a new query in another activity.
Solution 2:
The cursor lifecycle should be handled within an activity or you risk causing a memory leak, ideally pass the URI used to query for the cursor in the intent like
Intent intent = new Intent(this, SomeActivity.class);
intent.setData(uri);
startActivity(intent);
In the activity that answers this intent, query for the cursor using a loader and loader callbacks.
Post a Comment for "How Can I Pass Cursor To Another Activity?"