'For example, I need it to run as long as the values in the table day = Value 1 and in the table gender = boy

How to force execution in a "While" loop until it reaches a certain value in the database table. For example, I need it to run as long as the values in the table day = Value 1 and in the table gender = boy

The problem is that I just needed to replace the values in both "Day" and "Gender". And so that only those that meet these conditions are displayed in activity parameters

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_main);

        mDBHelper = new DatabaseHelper(this);

        try {
            mDBHelper.updateDataBase();
        } catch (IOException mIOException) {
            throw new Error("UnableToUpdateDatabase");
        }

        try {
            mDb = mDBHelper.getWritableDatabase();
        } catch (SQLException mSQLException) {
            throw mSQLException;
        }

      
        button = (Button) findViewById(R.id.button);
        textView = (TextView) findViewById(R.id.textView);

        

        // Список вправ
        ArrayList<HashMap<String, Object>> baseexercise = new ArrayList<HashMap<String, Object>>();

    // Список параметров конкретної вправи
        HashMap<String, Object> traininglist;

    // Отправляем запрос в БД
        Cursor cursor = mDb.rawQuery("SELECT * FROM baseexercise", null);
        cursor.moveToFirst();

    // Пробігаєм по всім вправам
        while (!cursor.isAfterLast()) {
            traininglist = new HashMap<String, Object>();

            //Імя таблиці і номер таблиці
            traininglist.put("exercise",  cursor.getString(4));
            traininglist.put("gender",  cursor.getString(1));
            traininglist.put("day",  cursor.getString(2));


            // Закидуємо вправу в список вправ
            baseexercise.add(traininglist);

            // Переходим до слідуючої вправи
            cursor.moveToNext();

        }
        cursor.close();

    // Які параметри вправи будемо відображати в відповідних елементах з розмітки adapter_item.xml
        String[] from = { "exercise", "day"};
        int[] to = { R.id.textView, R.id.textView2};

    // Адаптер
        SimpleAdapter adapter = new SimpleAdapter(this, baseexercise, R.layout.adapter_item, from, to);
        ListView listView = (ListView) findViewById(R.id.listView);
        listView.setAdapter(adapter);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source