title: How do I update the menuitem name in custom listview to sqlite database in android?
body: <p>I am new  to using sqlite databases. I have created a database as a test. And table as test. In test table I created two columns one is <code>key_id</code> another one is <code>menuname</code>.</p>
  
  <p>I inserted some <code>menunames</code> in test table along with key_id. I have then fetched <code>menunames</code> from sqlite database to custom listview using simplecursor adapter and then append to edittext:</p>
  
  <p><img src="https://i.stack.imgur.com/4xvs7.png" alt="enter image description here"></p>
  
  <p>The url contains my output screen shot. If I changed some <code>menunames</code> in edittext after click menu button in android it means it shows save button. If I click save button means what are I am edited menu names is replaced by old <code>menunames</code> or using <code>key_id</code>:</p>
  
  <p>How do I update the menuitem name in custom listview to sqlite database in android?</p>
  
  <p>I tried this code:</p>
  
  <pre><code>         public class EditMainMenu extends Activity {
  private SQLiteAdapter mySQLiteAdapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.editmainmenu);
      ListView listContent = (ListView) findViewById(R.id.contentlist);
      mySQLiteAdapter = new SQLiteAdapter(this);
      mySQLiteAdapter.openToWrite();
      final Cursor cursor = mySQLiteAdapter.queueAll();
      startManagingCursor(cursor);
  
      String[] from = new String[] { SQLiteAdapter.KEY_CONTENT };
      int[] to = new int[] { R.id.text };
  
      EditMainMenuListview adapter = new EditMainMenuListview(this,
              R.layout.editmainmenulistview, cursor, from, to);
  
      listContent.setAdapter(adapter);
      System.out.println("gouthampra");
  }
  
  public boolean onCreateOptionsMenu(Menu menu) {
      // TODO Auto-generated method stub
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.save, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // TODO Auto-generated method stub
      switch (item.getItemId()) {
      case R.id.save:
  
          break;
      case R.id.back:
          break;
  
      default:
          break;
      }
      return true;
  }
   }
  </code></pre>
  
  <p>EditMainMenuListview.java</p>
  
  <pre><code>              public class EditMainMenuListview extends SimpleCursorAdapter{
  
  Cursor c;
  Context context;
  Activity activity;
  
  public EditMainMenuListview(Context context, int layout, Cursor c,
          String[] from, int[] to) {
      super(context, layout, c, from, to);
  
      this.c = c;
      this.context=context;
      this.activity=(Activity) context;
  
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      if(convertView == null)
          convertView = View.inflate(context, R.layout.editmainmenulistview, null);
      View row = convertView;
  
      c.moveToPosition(position);
  
      EditText menuname = (EditText) convertView.findViewById(R.id.text);
  
    menuname.setFocusable(true);
      menuname.setText(c.getString(1));
  
  
      return(row);
  }
  </code></pre>