Handling orientation change with loaders and array adapters
<p>I am using loaders to load data into a gridview . First let me show you some code:-</p>

<pre><code>The Fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle icic){

    View v=inflater.inflate(R.layout.thegrid, container, false);
    final GridView gv = (GridView)v.findViewById(
            R.id.thegridview);
    gv.setAdapter(upAd);//upAd is the array adapter initialized in oncreate of the fragment

    gv.setOnItemClickListener(this);
    Bundle args=new Bundle();
    args.putString("page", String.valueOf(page));
    getLoaderManager().initLoader(1, args, this);

    return v;
}
@Override
public Loader&lt;ArrayList&lt;HashMap&lt;String, String&gt;&gt;&gt; onCreateLoader(int loaderId,Bundle thebundle) {

    if(loaderId==1){
        String page=thebundle.getString("page");
        return new MyLoader(getActivity().getApplicationContext(),page);
    }

    return null;
}


@Override
public void onLoadFinished(Loader&lt;ArrayList&lt;HashMap&lt;String, String&gt;&gt;&gt; theLoader,ArrayList&lt;HashMap&lt;String, String&gt;&gt; data) {
    upAd.addAll(data);
}
</code></pre>

<p>Now when the fragment is displayed , it shows a grid of 10 elements downloaded.Now when the screen orientation is changed, the loader behaves well and does not download the data again but it adds the same data again to the grid.. so i end up having a grid of 20 elements the same 10 repeated twice. Well i can call :-</p>

<pre><code>upAd.clear() 
</code></pre>

<p>in onLoadFinished but i want to avoid that.Could someone tell me what would I be doing wrong here.</p>
