title: How to update values in database using an update image button in custom list adapter?
body: <p>This is my custom list adapter. I want to update the values in table using the update ImageButton in the list. On clicking it, the old values should be shown in a new activity and then the edited value must be stored in the database. However, I am unable to pass an intent inside the onClick() method.</p>
  
  <p>Please suggest me a solution </p>
  
  <pre><code>public class CustomListAdapter extends BaseAdapter implements ListAdapter 
       { 
        private ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); 
        private Context context; 
        OnItemSelectedListener onItemSelectedListener;
        public int pos;
        String pass,pass2,edit,epass;
  
  
  public CustomListAdapter(List list, Context context) { 
      this.list = (ArrayList&lt;String&gt;) list; 
      this.context = context; 
  } 
  
  
  @Override
  public int getCount() { 
      return list.size(); 
  } 
  
  @Override
  public Object getItem(int pos) {
      //pass2 = list.toString();
      return list.get(pos); 
  } 
  
  //@Override
  //public Long getItemId(int pos) { 
  //    
  //    //just return 0 if your list items do not have an Id variable.
  //} 
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
          view = inflater.inflate(R.layout.layout_custom_list, null);
      } 
  
      //Handle TextView and display string from your list
      final TextView listItemText = (TextView)view.findViewById(R.id.list_item_string); 
      listItemText.setText(list.get(position)); 
  
  
  
  
  
  
      //Handle buttons and add onClickListeners
      ImageButton deleteBtn = (ImageButton)view.findViewById(R.id.delete_btn);
      ImageButton editBtn = (ImageButton)view.findViewById(R.id.edit_btn);
      //Button addBtn = (Button)view.findViewById(R.id.add_btn);
  
      deleteBtn.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v) { 
              //do something
              list.remove(position);
              pass = listItemText.getText().toString();
  
              notifyDataSetChanged();
              pass2 = pass.substring(0,pass.indexOf(' '));
              System.out.println(pass2);
              Moneydb.delete(pass2);
          }
      }); 
      editBtn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v2) {
              // TODO Auto-generated method stub
              edit=listItemText.getText().toString();
              epass = listItemText.getText().toString();
              edit = epass.substring(0,epass.indexOf(' '));
              Moneydb.edit(edit);
  
          }
      });
  
  
      return view; 
  }
  
  protected Context getContext() {
      // TODO Auto-generated method stub
      return null;
  }
  
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      //return list.get(position).getId();
      return 0;
  }
  
  
  public void clear() {
      //CustomListAdapter collection = null;
      // TODO Auto-generated method stub
      list.clear();
      notifyDataSetChanged();
  }
  </code></pre>