title: Android: Is it possible to update MatrixCursor line (as solution to views resetting on rotate)
body: <p>I am having trouble with a ListView based on a MatrixCursor resetting values on keyboard minimize and orientation change.  </p>
  
  <p>The matrix cursor is filled with data from a SQL database.  This is done because I want the original database columns to be rows in the listview:</p>
  
  <pre><code>public void fillList(boolean rewrite, int rewrite pos, int) {
      myCols = getColArray();    
      SQLiteDatabase myDB = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, SQLiteDatabase.OPEN_READONLY); 
      myCursor = myDB.query("Scoring", statCols, null, null, null, null, null);
  
      String[] menuCols = new String[] { "_id","Item","Value"};
      int []to = new int[]{R.id.listitem, R.id.listitem_value}; 
  
      mc = new MatrixCursor(menuCols);
  
      for (int i = 0; i &lt; (mChoices.size()); i++) {
          statCursor.moveToPosition(draftId);
          String item = mChoices.get(i);          
  
          String valueString = "";
          int valueCol = statCursor.getColumnIndex(item);
          int value = statCursor.getInt(valueCol);                      
          valueString = (String.valueOf(value));
  
          mc.addRow(new Object[] {
              i,
              item,
              valueString                                         
          });
      }
  </code></pre>
  
  <p>This fillList() method is called in my onCreate.  This cursor is then used to populate the ListView by extending SimpleCursorAdapter.  My goal for the fragement is to allow the user to click on one of the list items, causing Dialog with an EditText line to appear:</p>
  
  <pre><code>@Override
  public void onListItemClick(ListView l, final View v, int position, long id) {
  
      final TextView valueL = (TextView) v.findViewById(R.id.listitem_value);
      String valueString = (String) valueL.getText();
      int value = 100;
      try {
          value = Integer.parseInt(valueString);
      } catch(NumberFormatException nfe) {
      }
  
      //Create dialog layout
      View view = getActivity().getLayoutInflater().inflate(R.layout.numberpick_popup, null);
      final EditText mInputText = (EditText) view.findViewById(R.id.myText);
  
      //Create Dialog
      AlertDialog.Builder builder =  new AlertDialog.Builder(this.getActivity());
      builder.setTitle(title);
  
      builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              valueL.setText(mInputText.getText().toString());
              return;
          }
      });
  
      builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              return;
          }
      });
  
      builder.setView (view);
      final AlertDialog dialog = builder.create ();
      dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
      dialog.show();
  }
  </code></pre>
  
  <p>The problem I am having is when the fragment layout regenerates on keyboard hidden or orientation change, causing fillData to be called and overwriting any of the values I had updated in the list.  This happens if I choose OK on the dialog without first minimizing the keyboard, or on any orientation change.</p>
  
  <p>My thinking is that there should be some way to overwrite the values in the MatrixCursor when new data is entered from the dialog.  However I don't know if this is possible or if the cursor would even survive the state changes.</p>
  
  <p>Any help would be greatly appreciated.</p>