Saving the list of items after the user presses a button
<p>I have a list of items that are created from the results of website parsing using Jsoup, a task started when an image button is pressed. The results appear fine but when I press the back button on the phone and then go back into the activity the results disappear and the screen is blank. This means the user will have to press the button again.</p>

<p>So how do I go about preserving the list of items only once the image button has been pressed? </p>

<p>Thanks</p>

<p>Edit</p>

<p>I have looked at the Data Storage page on the Android site and have done the following:</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView( R.layout.new_sightings );

    // Store data once created
    SharedPreferences settings = getSharedPreferences( PREFS_NAME,0 );

    reload = (Button)findViewById( R.id.reloadTen );
    reload.setOnClickListener( this );

    list = getListView();
    list.setOnItemClickListener( new OnItemClickListener() 
    {

        @Override
        public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id ) 
        {
            // Start an activity based on what list view item is pressed
            Intent intent = new Intent( newSightings.this, newCompass.class );

            // Pass the data we retrieved to the next activity
            intent.putExtra( "info",data[position]  );
            startActivity( intent );
        }

    });
    list.setTextFilterEnabled( true );
    adapter = new ArrayAdapter&lt;String&gt;( this, android.R.layout.simple_list_item_1, listItems );
    setListAdapter( adapter );
}

@Override
protected void onStop() 
{
    super.onStop();

    SharedPreferences settings = getSharedPreferences( PREFS_NAME,0 );
    SharedPreferences.Editor editor = settings.edit();

    for( int i = 0; i &lt; data.length; i++ )
    {
        editor.putString( "sighting"+i,data[i].toString() );
    }
    editor.commit();
}
</code></pre>

<p>I know I haven't done much in the onCreate method as Im not really sure how to call the data back properly. There is a lot of data and the values are quite different for each key. Btw should i add to the shared preferences during the AsyncTask that actually gets the data? I'm a little confused on this one...</p>
