Q:

Android ArrayList with custom array for each row

How can I write the array on the ItemsScreenActivity activity, so that when pressing on each element, its corresponding values are added to database?

The issue now is that no matter what element I press, only coke 500 200 are added to database(because indeed, the code does only this).
  I want to have on my screen a list of items, for which I created an ArrayList. Each item in the arraylist corresponds to a custom row with three elements(for which I created a special layout and custom adapter).

public class ItemsScreenActivity extends AppCompatActivity {

    MyDBHandler myDb = new MyDBHandler(this);

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

        ListView ListView = (ListView)findViewById(R.id.myList);
    
            final ArrayList<DataModel> items = new ArrayList<DataModel>();
    
            final DataModel coke = new DataModel("Coke", "500", "200");
            items.add(cafea);
            final DataModel pepsi = new DataModel("Pepsi", "500", "200");
            items.add(espresso);
    
            ListAdapter myAdapter = new CustomAdapter(this, R.layout.custom_row, items);
            ListView myList = (ListView) findViewById(R.id.myList);
            myList.setAdapter(myAdapter);
      
            myList.setOnItemClickListener(
                    new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                            String itemType = coke.getitemType().toString();
                            String quantity = coke.getCantBautura().toString();
                            String calories = coke.getCantcalories().toString();
                            AddData(itemType, quantity, calories);
                        }
                    }
            );}
public void AddData(String itemType, String quantity, String calories) {
            boolean insertData = myDb.addData(itemType, quantity, calories);
}

A:

You need to change 
    final ArrayList<DataModel> items = new ArrayList<DataModel>();
    final DataModel coke = new DataModel("Coke", "500", "200");
    items.add(cafea);
    final DataModel pepsi = new DataModel("Pepsi", "500", "200");
    items.add(espresso);

to
        final ArrayList<DataModel> items = new ArrayList<DataModel>();
        final DataModel coke = new DataModel("Coke", "500", "200");
        items.add(coke );
        final DataModel pepsi = new DataModel("Pepsi", "500", "200");
        items.add(pepsi );

Currently, in your onclick , you are always addign coke data into db. Get the clicked object and add it.
 DataModel dataModel = (DataModel) myListView.getItemAtPosition(position);
 //  dataModel.name // "Coke"
 // dataModel.value  // "500"

