How to remove an item and refresh the listview
===

I have an listview in my program. In that i populated the values from the database and displayed. Iam using context menu to edit,delete items in listview. if i chose delete in the context menu it deletes the item in the database but i did'nt removed the item from the listview. What iam doing wrong here. Please help me if anybody knows.

Retrieve method:

    public void retrievedb() {
    		strquery = "SELECT * FROM api_settings";
    		Cursor mCursor = (MainscreenActivity.JEEMAAndroSMSDB).rawQuery(
    				strquery, null);
    		if (mCursor.getCount() != 0) {
    			mCursor.moveToLast();
    			for (int i = mCursor.getCount() - 1; i >= 0; i--) {
    				dbid = mCursor.getString(0);
    				dbapiname = mCursor.getString(1);
    				dbURL = mCursor.getString(2);
    				dbUnameVar = mCursor.getString(3);
    				dbUnameVal = mCursor.getString(4);
    				dbPwdVar = mCursor.getString(5);
    				dbPwdVal = mCursor.getString(6);
    				dbsendername = mCursor.getString(7);
    				dbdestinationvar = mCursor.getString(8);
    				dbmsgvariable = mCursor.getString(9);
    				dbchars = mCursor.getString(10);
    			}
    		}
    
    		if ((dbapiname == null) || (dbURL == null) || (dbUnameVar == null)
    				|| (dbUnameVal == null) || (dbPwdVar == null)
    				|| (dbPwdVal == null) || (dbsendername == null)
    				|| (dbdestinationvar == null) || (dbmsgvariable == null)
    				|| (dbchars == null)) {
    
    			tvText = (TextView) findViewById(android.R.id.text1);
    			tvText.setVisibility(1);
    		} else {
    			adapter = new ArrayAdapter<Settingsmodel>(this,
    					android.R.layout.simple_list_item_1, listItems);
    			tvText = (TextView) findViewById(android.R.id.text1);
    			tvText.setVisibility(View.GONE);
    			strquery = "SELECT ID,API_Name FROM api_settings";
    			mCursor = (MainscreenActivity.JEEMAAndroSMSDB).rawQuery(strquery,
    					null);
    			if (mCursor.getCount() != 0) {
    				mCursor.moveToFirst();
    				do {
    					dbid = mCursor.getString(0);
    					dbapiname = mCursor.getString(1);
    					listItems.add(new Settingsmodel(dbapiname, dbid));
    					adapter.notifyDataSetChanged();
    				} while (mCursor.moveToNext());
    			}
    		}
    	}

Context Menu:

    @Override
    	public void onCreateContextMenu(ContextMenu menu, final View v,
    			ContextMenuInfo menuInfo) {
    		if (v.getId() == android.R.id.list) {
    			AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    			Settingsmodel selectedValue = (Settingsmodel) getListAdapter()
    					.getItem(info.position);
    			String tempo = selectedValue.getSpinnerText();
    			menu.setHeaderTitle(tempo);
    			String[] menuItems = getResources().getStringArray(R.array.menu);
    			for (int i = 0; i < menuItems.length; i++) {
    				menu.add(Menu.NONE, i, i, menuItems[i]);
    			}
    
    		}
    	}
    
    	@Override
    	public boolean onContextItemSelected(MenuItem item) {
    		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
    				.getMenuInfo();
    		int menuItemIndex = item.getItemId();
    		String[] menuItems = getResources().getStringArray(R.array.menu);
    		String menuItemName = menuItems[menuItemIndex];
    		Settingsmodel selectedValue = (Settingsmodel) getListAdapter().getItem(
    				info.position);
    		String temp0 = selectedValue.getSpinnerText();
    		String temp1 = selectedValue.getValue();
    		int id = Integer.parseInt(temp1);
    		if (menuItemName.equalsIgnoreCase("Set as Default")) {
    			ContentValues values = new ContentValues();
    			values.put(MainscreenActivity.COL_Set_Default, value);
    			MainscreenActivity.JEEMAAndroSMSDB.update(
    					MainscreenActivity.TABLE_Name, values, "ID=" + id, null);
    			values.put(MainscreenActivity.COL_Set_Default, 0);
    			Toast.makeText(getBaseContext(), temp0 + " is set as Default",
    					Toast.LENGTH_LONG).show();
    			MainscreenActivity.JEEMAAndroSMSDB.update(
    					MainscreenActivity.TABLE_Name, values, "ID!=" + id, null);
    		}
    
    		if (menuItemName.equalsIgnoreCase("Delete")) {
    			MainscreenActivity.JEEMAAndroSMSDB.delete(
    					MainscreenActivity.TABLE_Name, "ID=" + id, null);			
    			Toast.makeText(getBaseContext(), "API Deleted Successfully",
    					Toast.LENGTH_SHORT).show();	
    			retrievedb();
    		}
    		
    		return true;
    	}