I’m an Android newbie and I’m trying to update my (working!) code that uses a cursor so that it uses a CursorLoader. My app begins with an Activity with a ListView with three choices, Beginning, Intermediate and Advanced. Depending on which item is chosen, I want to open a second Activity with another ListView. That ListView will be populated from a SQLite database where all the items have a level of e.g., Beginning. Elsewhere on stackoverflow, it was suggested to me that I insert an Activity between these two activities to handle the actual data retrieval. So now I have three Activities. One has a ListView with three choices. That one sends a String to the second Activity via an Intent. The second Activity queries the database and retrieves one column from all the records matching the level chosen into a CursorLoader. And here’s my question. I want to pass all this data to my third Activity so that the data can be displayed in a ListView. But how do I get the data out of the CursorLoader? I’m thinking I want to do something like:
Intent data = new Intent(getApplicationContext(), com.MyKnitCards.project.StitchList.class);
Bundle dataBundle = new Bundle();
dataBundle.getStringArrayList(myData);
where myData is an ArrayList of data from the CursorLoader. I have no idea how to do this. I’m wondering if I want to use LoaderManager to accomplish this, but I have no idea how to do this either.
Thanks in advance!
I would get rid of the middle man Activity that does the data retrieval and just do it in the Activity that displays the data. CursorLoader that automatically loads in the background so it won’t freeze your UI, and that way you don’t have to worry about passing data between activities.