custom listview delete not deleting
hi i would like to delete selected item in my custom listview. but deletion will only sucessful once. please review my code below and advice me the solution for it.

 if (exist == true){
	    db=SQLiteDatabase.openDatabase(fullpath, null, SQLiteDatabase.OPEN_READWRITE);
	    
	    final Cursor cur = db.query("tbl_Transaction", null, null, null, null, null, null);
	    
	    if(cur.getCount()==0){            
	        /*please ignore this block*/
	    }else{
	    	cur.moveToFirst();
	                
	        while(cur.isAfterLast()==false){
	        		
	        	temp1.put("Item Purchased",cur.getString(1));
	        	temp1.put("Quantity", cur.getString(2));
	        	temp1.put("Price", cur.getString(3));
	        	temp1.put("Total Price", cur.getString(4));
	        	temp1.put("Flag", cur.getString(5));
	        	temp1.put("DATE", cur.getString(6));
	        	list.add(temp1);
	        	temp1 = new HashMap<String, String>();
	        	cur.moveToNext(); 
	        	
	        }//while
	          
	        final ListAdapter adapter = new SimpleAdapter(this, list, R.layout.row, new String[] {"Item Purchased", "Quantity", "Price", "Total Price","Flag", "DATE"}, 
	        		new int[] {R.id.ITEM_CELL, R.id.QUANTITY_CELL, R.id.PRICE_CELL, R.id.TOTAL_CELL, R.id.FlAG_CELL, R.id.DATE_CELL});
	        this.setListAdapter(adapter);
	        final ListView lv = (ListView)findViewById(android.R.id.list);
			lv.setOnItemClickListener(new OnItemClickListener() {       	
			    @Override
			    public void onItemClick(AdapterView<?> a, View view,int position, long id) {		       
			    	//Toast.makeText(getApplicationContext(), position+"", Toast.LENGTH_SHORT).show(); 
			    	//Cursor cursor = (Cursor) ((SimpleCursorAdapter)lv.getAdapter()).getItem(position);
			    	alist.add(position+"");
			    	//delitem();
			    }
			});
			
			
			final Button buttonView;
			buttonView = (Button)findViewById(R.id.button1);
			buttonView.setOnClickListener(new Button.OnClickListener() {           
				public void onClick(View v){
					SQLiteDatabase db1 = SQLiteDatabase.openDatabase(fullpath, null, SQLiteDatabase.OPEN_READWRITE);
					HashSet hs = new HashSet(); 
					hs.addAll(alist);
					alist.clear(); 
					alist.addAll(hs);
					//Toast.makeText(getApplicationContext(), alist.size()+"", Toast.LENGTH_SHORT).show();
					
					for (int i = 0; i < (alist.size()); i++)
					{
						//String where = "id = " + alist.get(i); 
						//db.delete("tbl_transaction", where, null);
						//db1.rawQuery("delete from tbl_Transaction where id = "+ alist.get(i), null);
						//String where = "id = " + i; 
				    	//db1.delete("tbl_Transaction", where, null); 
						Toast.makeText(getApplicationContext(), "data "+ alist.get(i), Toast.LENGTH_SHORT).show();
						db1.execSQL("delete from tbl_Transaction where id ="+ alist.get(i));
						Toast.makeText(getApplicationContext(), "data deleted", Toast.LENGTH_SHORT).show();	
						//lv.setBackgroundColor(Color.parseColor("#FFFFFF"));
						
					}//for loop
					
					Toast.makeText(getApplicationContext(),"Count = "+ adapter.getCount()+"", Toast.LENGTH_SHORT).show();
					db1.close();
					
					}//onclick 
				
				});//setonclicklistener
			
			db.close();
			cur.close();
	    }//else
	     
	}//if exist
custom listview delete not deleting
===

hi i would like to delete selected item in my custom listview. but deletion will only sucessful once. please review my code below and advice me the solution for it.

 if (exist == true){
	    db=SQLiteDatabase.openDatabase(fullpath, null, SQLiteDatabase.OPEN_READWRITE);
	    
	    final Cursor cur = db.query("tbl_Transaction", null, null, null, null, null, null);
	    
	    if(cur.getCount()==0){            
	        /*please ignore this block*/
	    }else{
	    	cur.moveToFirst();
	                
	        while(cur.isAfterLast()==false){
	        		
	        	temp1.put("Item Purchased",cur.getString(1));
	        	temp1.put("Quantity", cur.getString(2));
	        	temp1.put("Price", cur.getString(3));
	        	temp1.put("Total Price", cur.getString(4));
	        	temp1.put("Flag", cur.getString(5));
	        	temp1.put("DATE", cur.getString(6));
	        	list.add(temp1);
	        	temp1 = new HashMap<String, String>();
	        	cur.moveToNext(); 
	        	
	        }//while
	          
	        final ListAdapter adapter = new SimpleAdapter(this, list, R.layout.row, new String[] {"Item Purchased", "Quantity", "Price", "Total Price","Flag", "DATE"}, 
	        		new int[] {R.id.ITEM_CELL, R.id.QUANTITY_CELL, R.id.PRICE_CELL, R.id.TOTAL_CELL, R.id.FlAG_CELL, R.id.DATE_CELL});
	        this.setListAdapter(adapter);
	        final ListView lv = (ListView)findViewById(android.R.id.list);
			lv.setOnItemClickListener(new OnItemClickListener() {       	
			    @Override
			    public void onItemClick(AdapterView<?> a, View view,int position, long id) {		       
			    	//Toast.makeText(getApplicationContext(), position+"", Toast.LENGTH_SHORT).show(); 
			    	//Cursor cursor = (Cursor) ((SimpleCursorAdapter)lv.getAdapter()).getItem(position);
			    	alist.add(position+"");
			    	//delitem();
			    }
			});
			
			
			final Button buttonView;
			buttonView = (Button)findViewById(R.id.button1);
			buttonView.setOnClickListener(new Button.OnClickListener() {           
				public void onClick(View v){
					SQLiteDatabase db1 = SQLiteDatabase.openDatabase(fullpath, null, SQLiteDatabase.OPEN_READWRITE);
					HashSet hs = new HashSet(); 
					hs.addAll(alist);
					alist.clear(); 
					alist.addAll(hs);
					//Toast.makeText(getApplicationContext(), alist.size()+"", Toast.LENGTH_SHORT).show();
					
					for (int i = 0; i < (alist.size()); i++)
					{
						//String where = "id = " + alist.get(i); 
						//db.delete("tbl_transaction", where, null);
						//db1.rawQuery("delete from tbl_Transaction where id = "+ alist.get(i), null);
						//String where = "id = " + i; 
				    	//db1.delete("tbl_Transaction", where, null); 
						Toast.makeText(getApplicationContext(), "data "+ alist.get(i), Toast.LENGTH_SHORT).show();
						db1.execSQL("delete from tbl_Transaction where id ="+ alist.get(i));
						Toast.makeText(getApplicationContext(), "data deleted", Toast.LENGTH_SHORT).show();	
						//lv.setBackgroundColor(Color.parseColor("#FFFFFF"));
						
					}//for loop
					
					Toast.makeText(getApplicationContext(),"Count = "+ adapter.getCount()+"", Toast.LENGTH_SHORT).show();
					db1.close();
					
					}//onclick 
				
				});//setonclicklistener
			
			db.close();
			cur.close();
	    }//else
	     
	}//if exist