I need to check if there are any values in the table.
request code
public int getWordsCount(String language) { Cursor cursor_result = null; int count = 0; try { cursor_result = dataBase.rawQuery("SELECT COUNT(*) FROM " + MyDataBase.TABLE_WORDS + " WHERE " + MyDataBase.LANGUAGE + " = '" + language + "'"); count = cursor_result.getCount(); cursor_result.close(); return count; } finally { if (cursor_result != null) cursor_result.close(); return count; } } adapter code
@Override public void onBindViewHolder(final ViewHolder holder, final int position) { Language item = languageList.get(position); holder.tvLang.setText(item.getLanguage_ru()); if (item.loading) { holder.download.setVisibility(View.GONE); holder.proDown.setVisibility(View.VISIBLE); } else { int count = ManagerDataBase.getInstance().getWordsCount(item.language); if (count > 0) { holder.tvLang.setTextColor(Color.BLACK); holder.proDown.setVisibility(View.GONE); holder.download.setVisibility(View.GONE); } else { holder.tvLang.setTextColor(Color.GRAY); holder.proDown.setVisibility(View.GONE); holder.download.setVisibility(View.VISIBLE); } } if (item.language.equals(lang)) { holder.layoutLang.setBackgroundResource(R.drawable.background); holder.tvLang.setTextColor(Color.WHITE); } } My problem is that in any case only the first part of the condition is fulfilled, although in MyDataBase.LANGUAGE I pass different values in the adapter for each element. The adapter is inherited from RecyclerView.Adapter<AdapterPharmacy.ViewHolder>