this code doesn't delete the element which I pressed its button ,but it deletes the last element in the cursor.

here's my button with the Listener

ImageButton imageButton =convertView.findViewById(R.id.order_cancel);
            imageButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                        db.execSQL("DELETE FROM ordersTable WHERE _id = ? ;", new String[]{String.valueOf(cursor.getInt(cursor.getColumnIndex("_id")))});
                    cursor.requery();
                 notifyDataSetChanged();
                }
            });
0

There are 0 best solutions below