In my application, it has two tabs, one of which is a reminder, and the other is a completed task.

When the toggle button is pressed, I want it to move the list to the Finished task.
The idea is this:
- Get verified row id from sqlite
- Get the data based on the identifier from the reminder table and insert it into the completed table.
- Call the return method in the Completed tab.
But when I pressed the switch button and navigated to "Finished", it is still empty. After I exit the application and swipe the tab, only data will be displayed.
How can I make data right away on the Finished tab when it scrolls, rather than exit the application and open it again? Thanks
AllAdapter (Reminder)
holder.toggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (((ToggleButton)v).isChecked()) { int getPosition = (Integer) v.getTag(); // Here we get the position that we have set for the checkbox using setTag. search.get(getPosition).setSelected(((ToggleButton) v).isChecked()); int id= search.get(getPosition).getID(); mdb = new MyDatabaseHelper(v.getContext()); database = mdb.getReadableDatabase(); Cursor cursor = database.rawQuery("SELECT * FROM " + MyDatabaseHelper.TABLE__TASK + " WHERE ID = ? ", new String[]{id+""}, null); if (cursor != null && cursor.getCount() > 0) { while (cursor.moveToNext()) { String allTask = cursor.getString(cursor.getColumnIndex("Title")); String name = cursor.getString(cursor.getColumnIndex("Name")); String allTime = cursor.getString(cursor.getColumnIndex("Time")); String allDate = cursor.getString(cursor.getColumnIndex("Date")); insertDataToCompleteTab(id,name,allTask,allTime,allDate); // insert to another table } } } else { int getPosition = (Integer) v.getTag(); // Here we get the position that we have set for the checkbox using setTag. search.get(getPosition).setSelected(((ToggleButton) v).isChecked()); } } });
CompletedTask
retrieveList(name); public void retrieveList(String name) { Toast.makeText(getActivity(),name,Toast.LENGTH_SHORT).show(); search.clear(); database = mdb.getReadableDatabase(); Cursor cursor = database.rawQuery("SELECT * FROM " + MyDatabaseHelper.TABLE_TASKCOMPLETED + " WHERE Name = ? ", new String[]{name}, null); if (cursor != null && cursor.getCount() > 0) { while (cursor.moveToNext()) { int iD = cursor.getInt(cursor.getColumnIndex("ID")); String allTask = cursor.getString(cursor.getColumnIndex("Title")); String allTime = cursor.getString(cursor.getColumnIndex("Time")); String allDate = cursor.getString(cursor.getColumnIndex("Date")); if (adapter != null) { adapter.add(iD, allTask, allTime, allDate); listview.setAdapter(adapter); adapter.getCount();
Alladapter
http://pastebin.com/qbLDtf4v
Completed tab
http://pastebin.com/WCCbZ0h4
CompleteAdapter
http://pastebin.com/QdbuTQKm