title: Delete Row By id from SQLdatabase in Android
body: <p>I’m Trying to Delete a row of listview from the list adapter where if a button is clicked it will look for the id and send it to the database for deletion. The method I wrote return the last id available and not the selected one. 
  Here is the list Adapter </p>
  
  <pre><code>public class HistoryAdapter extends ArrayAdapter&lt;NassrahHelper&gt; {
  int ID;
  public HistoryAdapter(@NonNull Context context, ArrayList&lt;NassrahHelper&gt; resource) {
      super (context, R.layout.history_listadapter ,resource);
  }
  
  @NonNull
  @Override
  public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
      LayoutInflater ListInflate = LayoutInflater.from(getContext ());
  
      ValuesHelper data = getItem(position);
  
      View customView = ListInflate.inflate (R.layout.history_listadapter,parent,false);
  
      ID = data.H_ID;
  
      String first = data.Date;
      TextView date = (TextView) customView.findViewById (R.id.DateText);
  
      TextView DeleteBtn = (TextView) customView.findViewById(R.id.DeleteText);
  
      DeleteBtn.setOnClickListener(
              new View.OnClickListener() {
                  public void onClick(View view) {
                      DeleteRecord();
                  }
              }
      );
  
      date.setText (first);
      return customView;
  }
  private void DeleteRecord() {        
          DataBaseHelper dataBaseHelper = new DataBaseHelper(getContext());
                      dataBaseHelper.DeleteHistoryRow(ID);
                      dataBaseHelper.close();
  
  }
  </code></pre>
  
  <p>This is the Database Class : </p>
  
  <pre><code>public boolean DeleteHistoryRow(int id) {
  SQLiteDatabase database = this.getWritableDatabase ();
  
  database.delete (HISTORY_TABLE, "ID = ?", new String[]{String.valueOf(id)});
  Log.w ("DELETE History", "DELTE Secssuffle");
  database.close ();
  return true;
  </code></pre>
  
  <p>}</p>