title: Custom SimpleCursorAdapter - refresh, update DB
body: <p>My issue today is related to a custom <code>SimpleCursorAdapter</code> I've implemented. Here are my activities <code>onCreate()</code> and the custom <code>SimpleCursorAdapter</code> :</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      customSharedPreference = getSharedPreferences("myCustomSharedPrefs", Activity.MODE_PRIVATE);
      editor = customSharedPreference.edit();
  
      setContentView(R.layout.activity_1);
      op = new OperationsClass(getApplicationContext());
      op.open();
  
      Cursor cursor = op.getList();
      startManagingCursor(cursor);
  
      String[] columns = new String[] { "AAA", "BBB", "CCC"};
      int[] to = new int[] { R.id.entry_aaa,R.id.entry_bbb, R.id.entry_ccc};
  
      MyCursorAdapter mAdapter = new MyCursorAdapter(this, R.layout.custom_entry, cursor, columns, to);
  
      this.setListAdapter(mAdapter);
  
      op.close();
  }
  </code></pre>
  
  <p><code>OperationsClass</code> manages a database and the <code>getList(</code>) function returns a cursor of the entries.</p>
  
  <pre><code>public class MyCursorAdapter extends SimpleCursorAdapter{
  
          private Context context;
          private MyCursorAdapter here = this;
  
          private int layout;
  
          public MyCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to) {
              super(context, layout, c, from, to);
              this.context = context;
              this.layout = layout;
          }
  
          @Override
          public View newView(final Context context, Cursor cursor, ViewGroup parent) {
  
              Cursor c = getCursor();
  
              final LayoutInflater inflater = LayoutInflater.from(context);
              View v = inflater.inflate(layout, parent, false);
  
              int col1 = c.getColumnIndex("aaa");
              String name1 = c.getString(col1 );
              int col2 = c.getColumnIndex("bbb");
              String name2 = c.getString(col2 );
              int col3 = c.getColumnIndex("ccc");
              int name3 = c.getInt(col3 );
  
              final TextView text1 = (TextView) v.findViewById(R.id.entry_aaa);
              final TextView text2 = (TextView) v.findViewById(R.id.entry_bbb);
              final TextView text3 = (TextView) v.findViewById(R.id.entry_ccc);
  
              text1.setText(name);
              text2.setText(name2);
  
              if (name3 == 0)
                  text3.setText("Not checked");
              else {
                  text3.setText("Checked");
                  text3.setOnClickListener(new View.OnClickListener()
                      {
                          public void onClick(View view)
                          {
                          text3.setText("Not checked");
                              // Here I would like to update my DB using
                              // OperationsClass and the SharedPrefs,
                              // and refresh the ListView with the new
                              // text value.
                          }
                      });
                  }
              }
              return v;
          }
  
          @Override
          public void bindView(View v, final Context context, Cursor c) {
              // Same operations as higher
          }
  }
  </code></pre>
  
  <p>Basically what I want to achieve is to refresh the <code>ListView</code> when the users clicks on the third column, which means its value changes (has been clicked or has not been). In the same time I wish to update the DB and the <code>SharedPreferences</code>(I could create a new object of both classes and recover from the application context, but that seems pretty heavy).</p>
  
  <hr>
  
  <p>I also wish to know if there is a way to trigger one of the implemented methods in one activity when an <code>AlertDialog</code> has been opened (in the same app, I actually want to add an element to my database through an <code>AlertDialog</code> and make the Activity that popped it up retrieve a new cursor and refresh its List).</p>