title: How to update latest changes in Database to appear on Recyclerview on remove/add immediately?
body: <p>How can I make the changes that happends in the database like delete/add to immediately be shown in the recyclerView too? I have tried notifyDataSetChanged(); and deleted from the arraylist directly too and reloaded the database list again. But all this seems like a messy work-around code and dosn't work?</p>
  
  <p>Here is a video of a delete action in my app which shows how it is right now.</p>
  
  <p><a href="https://www.youtube.com/watch?v=fCJnunOWBR4" rel="nofollow">https://www.youtube.com/watch?v=fCJnunOWBR4</a></p>
  
  <p><strong>This is the activity that starts when the user clicks on an event from the recyclerview:</strong> </p>
  
  <pre><code> public class EventActivity extends AppCompatActivity {
  
     @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.event_activity);
  
      loadDatabaseData(this);
      rvAdapter = new RvAdapter(databaseList, this);
  
  
      setSupportActionBar(toolbar);
      toolbar.setTitleTextColor(Color.WHITE);
      toolbar.showOverflowMenu();
      getSupportActionBar().setTitle(getIntent().getStringExtra("TITLE"));
  
      pos = getIntent().getIntExtra("POS",0);
  
  
  }
  
   //Delete or remove happends here:---------------------
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
  
          case R.id.menu_saveToDb:
              DbHelper.getInstance(EventActivity.this).saveToDb(eventID, title, description, subtitle, start, end, 1, url, imgURL);
              loadDatabaseData(getApplicationContext());
  
              break;
  
          case R.id.delete_from_Db:
  
              DbHelper.getInstance(EventActivity.this).deleteEvent(eventID);
  
              //these 3 lines dosn't help either
              loadDatabaseData(this);
              rvAdapter.notifyItemRemoved(pos);
              rvAdapter.notifyDataSetChanged();
  
              finish();
  
              break;
  
          default:
      }
      return super.onOptionsItemSelected(item);
  }
  
  
  
  public void loadDatabaseData(Context context) {
  
      databaseList = new ArrayList&lt;&gt;();
  
      dbHelper = new DbHelper(context);
      sqLiteDatabase = dbHelper.getWritableDatabase();
      Cursor c = sqLiteDatabase.rawQuery("SELECT * FROM " + DbHelper.DATABASE_NAME, null);
      EventCurserWrapper wrapper = new EventCurserWrapper(c);
  
      if (c.moveToFirst()) {
          while (!c.isAfterLast()) {
              databaseList.add(new Event(wrapper.getEvent().getEventID(),wrapper.getEvent().getTitle(), wrapper.getEvent().subtitle, wrapper.getEvent().getDescrption(), wrapper.getEvent().startTime, wrapper.getEvent().endTime, wrapper.getEvent().url,wrapper.getEvent().getImgURL(), wrapper.getEvent().isDb));
              c.moveToNext();
          }
      }
  
      wrapper.close();
      c.close();
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>This is the MainActivity that has the recyclerView:</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private RecyclerView recyclerView;
  public RvAdapter rvAdapter;
  private List&lt;Event&gt; databaseList, allEventsList, jsonList;
  private DbHelper dbHelper;
  private SQLiteDatabase sqLiteDatabase;
  private Toolbar toolbar;
  private SharedPreferences preferences;
  
  private static final String URL = "http://events.makeable.dk/api/getEvents";
  private static final String DESCRIPTION = "description_english";
  private static final String TITLE = "title_english";
  private static final String SUBTITLE = "subtitle_english";
  private static final String PICTURE_URL = "picture_name";
  private static final String EVENT_ID = "eventid";
  private static final String DATES = "datelist";
  private static final String EVENT_URL = "url";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      dbHelper = new DbHelper(this);
      preferences = PreferenceManager.getDefaultSharedPreferences(this);
      int showListPref = preferences.getInt("SHOW_LIST", 3);
  
      databaseList = new ArrayList&lt;&gt;();
      jsonList = new ArrayList&lt;&gt;();
  
  
      loadDatabaseData(this);
      new JsonParser().execute();
  
  
      toolbar = (Toolbar) findViewById(R.id.toolbar2);
      toolbar.setTitleTextColor(Color.WHITE);
      toolbar.showOverflowMenu();
      setSupportActionBar(toolbar);
      getSupportActionBar().setTitle("Events in Arhus");
  
  
  public void loadDatabaseData(Context context) {
  
      dbHelper = new DbHelper(context);
      sqLiteDatabase = dbHelper.getWritableDatabase();
      Cursor c = sqLiteDatabase.rawQuery("SELECT * FROM " + DbHelper.DATABASE_NAME, null);
      EventCurserWrapper wrapper = new EventCurserWrapper(c);
  
      if (c.moveToFirst()) {
          while (!c.isAfterLast()) {
              databaseList.add(new Event(wrapper.getEvent().getEventID(),wrapper.getEvent().getTitle(), wrapper.getEvent().subtitle, wrapper.getEvent().getDescrption(), wrapper.getEvent().startTime, wrapper.getEvent().endTime, wrapper.getEvent().url,wrapper.getEvent().getImgURL(), wrapper.getEvent().isDb));
              c.moveToNext();
          }
      }
  
      wrapper.close();
      c.close();
      sqLiteDatabase.close();
  
  }
  
  
  
  public void initRecyclerView(List&lt;Event&gt; list) {
  
      recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
      recyclerView.setLayoutManager(new LinearLayoutManager(this));
  
      rvAdapter = new RvAdapter(list, this);
      recyclerView.setAdapter(rvAdapter);
      rvAdapter.notifyDataSetChanged();
  
  }
  </code></pre>
  
  <p>}</p>