cache data in Android for search interface and avoid calling Web Service again
<p>I have a Restful Web Service that connects a Android client to the external database.</p>

<p>I create a list of data which I read from the database and show in the List View.</p>

<p>I create a search interface for my list as described in : <a href="http://www.edumobile.org/android/android-programming-tutorials/search-interface/" rel="nofollow">http://www.edumobile.org/android/android-programming-tutorials/search-interface/</a>  (you can see the images at the end of this page)
Actually it provides a Search Dialog for the application.</p>

<p>When I click on the search button, this search interface comes up. 
When I write a text to search, @onCreate method will be called and private variables are created again. It connects to the Web Service again. It can be really time consuming when we have lots of data.</p>

<p>Next time when I want to search in the same interface, everything works fine and It cashed the data.</p>

<p>Do you know how can I cash the data in the first time?
I made a ugly implementation myself : </p>

<pre><code>private static class cache{
        static List&lt;Project&gt; list  = new ArrayList&lt;Project&gt;(); 
    }

// When page comes up
if(cache.list.size() == 0) {    
    String str = client.getBaseURI("task/project/get/" + user); // Json format
    setAdapter(str); // class format    
    for(Project p : adapter)
           cache.list.add(p);
} else    //To avoid calling the web service
       for (Project p : cache.list)
       adapter.add(p);
</code></pre>

<p>I appreciate for any help.</p>
