I have an activity which implements a fragment where all of this code lives. This is best explained through an example as the code is confidential. This example mirrors what is trying to be done and what I observed through testing
ex.) I have a rss reader fragment that fetches two unique objects (A, B) from two unique Loaders with Loader Id's (Loader 1, Loader2)
Object A:
int[] fullArticleIdList;
List<ArticlePreview> partialArcticlePreviewList;
Object B:
List<ArticlePreview> partialArcticlePreviewList;
At creation I call "initloader" on Loader 1 which fetches object A. After scrolling through the available articles it hits the bottom of the partialArcticlePreviewList returned from object A and fetches more articles using "restartloader on Loader 2 which fetches object B and allows the user to read them and continues to do this for all the articles.
This works fine until the user rotates the devices thus calling onCreate. Now when initloader is called on Loader 1, it immediately jumps to onLoadFinished after connecting to loader 1 and returns a Loader 1. While the articleIds are returned properly, the partialArcticlePreviewList returned is the one from Loader 2 that fetched object B.
Does loader manager only keep one instance of an object around in cache and share it between multiple loaders? It would seem from extensive testing (5+ hours trying to find the problem and looking at loader ID's/Caches/Addresses in the Eclipse Debugger) that it overwrote Loader 1's partialArcticlePreviewList with the data it recieved in Loader 2's partialArcticlePreviewList. While this situation is ideal for a single Loader I would have thought that each Loaders' cache would be seperate. Obviously one of the advantages of loaders was their ease of use and persistence through screen rotation and data caching but it doesn't seem to work as implied. We've circumvented the problem by retaining an instance of the fragment and writing the appropriate code in onCreateView and onDestroyView to avoid memory leaks but is this a good solution?
EDIT: Forgot to add, we're using the compatibility library v4. Also, looking at the android source for the loaders didn't seem to shed any light on the situation as to why the loader is returning the wrong data for it's "mId".