How to refresh CursorAdapter on spinner selection?
<p>I have a SpinnerListner class that is nested in ListActivity   inherited class. My aim is to update the CursorAdapter that is implemented by the ListActivity class.</p>

<p>Here is my code:</p>

<pre><code>public class test extends ListActivity {

    private testAdapter     adapter;
    protected SQLiteDatabase        db;
    protected Cursor                cursor;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Display wrapper  
        setContentView(R.layout.wrapper);

        // Query Database 
        db = (new DatabaseHelper(this)).getWritableDatabase();
        cursor = getCursor();
        adapter = new testAdapter(this, cursor);


        setListAdapter(adapter);
    }

    public class SpinnerListener implements OnItemSelectedListener {

        @Override
        public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
          Toast.makeText(parent.getContext(), "The planet is " +  parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();

            String[] values = getResources().getStringArray(R.array.values);

            SharedPreferences.Editor editor = pref.preferences.edit();
            editor.putString("planet", values[pos]);
            editor.commit();

            // notifyDataSetChanged is not working
            adapter.notifyDataSetChanged();

            // requery is not working either
            cursor.requery();
        }

        @Override
        public void onNothingSelected(AdapterView&lt;?&gt; parent) {
          // Do nothing.
        }
    }
}
</code></pre>

<p>Both requery() and notifyDataSetChanged() are not working. What am I doing wrong here?</p>
