Created a list using Recyclerview. There was a problem. After writing data to the database, a new item appears only after restarting the application. Please explain how to make this list updated.
using this method I get data from the database
public List<CategoryList> getTodayItems() throws SQLException, ParseException { open(); categoriesList = new ArrayList<>(); String strSQL = "select category_name, category_photo, operat_date, operat_sum\n" + "from source, income, operations\n" + "where source._id = id_source and operations._id = id_of_transaction and operat_date LIKE '" + getCurrentDate() + "%'" + " order by operat_date DESC"; Cursor c = database.rawQuery(strSQL, null); if (c.moveToFirst()) { // определяем номера столбцов по имени в выборке int nameIndex = c.getColumnIndex(dbHelper.COLUMN_NAME); int photoIndex = c.getColumnIndex(dbHelper.COLUMN_PHOTO); int dateIndex = c.getColumnIndex(dbHelper.COLUMN_OPERAT_DATE); int sumIndex = c.getColumnIndex(dbHelper.COLUMN_OPERAT_SUM); do { categoriesList.add(new CategoryList(c.getString(nameIndex), c.getInt(photoIndex), "Мои деньги", String.valueOf(c.getInt(sumIndex)), String.valueOf(makeDate(String.valueOf(c.getLong(dateIndex)))))); // получаем значения по номерам столбцов Log.d(LOG_TAG, "NAME = " + c.getString(nameIndex) + " PHOTO = " + c.getInt(photoIndex) + " DATE = " + c.getInt(dateIndex) + " SUM = " + c.getInt(sumIndex)); } while (c.moveToNext()); } close(); return categoriesList; } then I do this:
categoriesListsToday = myDb.getTodayItems(); final CategoryListAdapter adapterList = new CategoryListAdapter(categoriesListsToday, new CategoryListAdapter.OnItemClickListener() { @Override public void onItemClick(CategoryList category) { // } }); rvList.setAdapter(adapterList);
myDb.add(category, textView_sum, true); categoriesListsToday.clear(); categoriesListsToday.addAll(categoriesListsToday); adapterList.notifyDataSetChanged();, if yes, then why it didn't help - java