I'm trying to make a laundry ordering application. I've made it to the order process, at the end of the order process, the user clicks the next button to checkout the ordered results, I have successfully made the checkout results, but what I made is still in one variable string. how to put the checkout results into an array variable so that I can post the results in the form of JSONArray?

HERE IS MY ORDER ACTIVITY CODE :

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

    // menghubungkan variablel pada layout dan pada java
    listProduk   = (ListView)findViewById(R.id.list_produk);
    swipeProduct = (SwipeRefreshLayout)findViewById(R.id.swipeProduct);
    radioExpress = (RadioButton)findViewById(R.id.radio_express);
    radioReguler = (RadioButton)findViewById(R.id.radio_regular);
    tvTotal      = (TextView)findViewById(R.id.total);
    next         = (Button)findViewById(R.id.button_next);
    actionBar    = getSupportActionBar();

    laundry_id = getIntent().getStringExtra(TAG_LAUNDRY_ID);

    // untuk mengisi data dari JSON ke dalam adapter
    productAdapter = new CheckboxAdapter(this, (ArrayList<ProductModel>) productList, this);
    listProduk.setAdapter(productAdapter);
    listProduk.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            productAdapter.setCheckBox(position);

        }
    });

    // menampilkan widget refresh
    swipeProduct.setOnRefreshListener(this);

    swipeProduct.post(new Runnable() {
                   @Override
                   public void run() {
                       swipeProduct.setRefreshing(true);
                       productList.clear();
                       tvTotal.setText(String.valueOf(0));
                       radioReguler.isChecked();
                       regular = true;
                       productAdapter.notifyDataSetChanged();
                       callProduct();
                   }
               }
    );

    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String checkbox = "";
            for (ProductModel hold : productAdapter.getAllData()) {
                int total = Integer.parseInt(hold.getProduct_price())*(hold.getCountProduct());
                if (hold.isCheckbox()) {
                    checkbox += "\n" + hold.getProduct_name() + " " + total;
                }
            }
            if (!checkbox.isEmpty()) {
                dipilih = checkbox;
            } else {
                dipilih = "Anda Belum Memilih Menu.";
            }

            formSubmit(dipilih);
        }
    });

}

private void formSubmit(String hasil){
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    LayoutInflater inflater = getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.form_submit, null);
    dialog.setView(dialogView);
    dialog.setIcon(R.mipmap.ic_launcher);
    dialog.setTitle("Menu Yang Dipilih");
    dialog.setCancelable(true);

    txtnamaProduk = (TextView) dialogView.findViewById(R.id.txtNama_produk);

    txtnamaProduk.setText(hasil);

    dialog.setNeutralButton("CLOSE", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

```

AND HERE IS THE CODE OF THE RESULT :

```
next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String checkbox = "";
            for (ProductModel hold : productAdapter.getAllData()) {
                int total = Integer.parseInt(hold.getProduct_price())*(hold.getCountProduct());
                if (hold.isCheckbox()) {
                    checkbox += "\n" + hold.getProduct_name() + " " + total;
                }
            }
            if (!checkbox.isEmpty()) {
                dipilih = checkbox;
            } else {
                dipilih = "Anda Belum Memilih Menu.";
            }

            formSubmit(dipilih);
        }
    });

}

```

in my code above, I still use the variable checkbox to accommodate all the results of the order chosen by the user. how to put all the result into array variable so i can post to server as a JSONArray? Please help me to solve this problem. because i'm still a beginner in android.

HERE IS MY ADAPTER CODE IF NEEDED :

```
public class CheckboxAdapter extends BaseAdapter{
private Context context;
private ArrayList<ProductModel> productItems;
ProdukLaundry produk;

public CheckboxAdapter(Context context, ArrayList<ProductModel> items, ProdukLaundry produk) {
    this.context      = context;
    this.productItems  = items;
    this.produk        = produk;
}

@Override
public int getItemViewType(int position) {

    return position;
}

@Override
public int getCount() {
    return productItems.size();
}

@Override
public Object getItem(int position) {
    return productItems.get(position);
}

@Override
public long getItemId(int position) {
    return 0;
}
@Override
public View getView(final int position, View view, ViewGroup parent) {
    final ViewHolder viewHolder;
    final ProductModel items = productItems.get(position);

    if(view == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view                  = inflater.inflate(R.layout.list_produk, null, true);
        viewHolder.checkBox = (CheckBox) view.findViewById(R.id.checkBox_productName);
        viewHolder.decrease = (TextView) view.findViewById(R.id.decrease_product);
        viewHolder.count    = (TextView) view.findViewById(R.id.count_product);
        viewHolder.increase = (TextView) view.findViewById(R.id.increase_product);
        viewHolder.price    = (TextView) view.findViewById(R.id.product_price);
        view.setTag(viewHolder);
    }else{
        viewHolder = (ViewHolder) view.getTag();
    }
    viewHolder.checkBox.setText(items.getProduct_name());
    viewHolder.price.setText(items.getProduct_price());
    viewHolder.count.setText(String.valueOf(items.getCountProduct()));

    //fungsi untuk set posisi textview + dan -
    viewHolder.increase.setTag(R.integer.btn_plus_view, view);
    viewHolder.increase.setTag(R.integer.btn_plus_pos, position);
    viewHolder.decrease.setTag(R.integer.btn_minus_view, view);
    viewHolder.decrease.setTag(R.integer.btn_minus_pos, position);

    //fungsi untuk disable textview + dan - jika checkbox tidak di klik
    viewHolder.decrease.setOnClickListener(null);
    viewHolder.increase.setOnClickListener(null);

    if(items.isCheckbox()){
        viewHolder.checkBox.setChecked(true);
        viewHolder.increase.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                View tempview = (View) viewHolder.increase.getTag(R.integer.btn_plus_view);
                TextView tv   = (TextView) tempview.findViewById(R.id.count_product);
                Integer pos   = (Integer) viewHolder.increase.getTag(R.integer.btn_plus_pos);

                int countProduct = Integer.parseInt(tv.getText().toString()) + 1;
                tv.setText(String.valueOf(countProduct));
                productItems.get(pos).setCountProduct(countProduct);
                produk.tambah(pos);
            }
        });
        viewHolder.decrease.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                View tempview = (View)viewHolder.decrease.getTag(R.integer.btn_minus_view);
                TextView tv   = (TextView) tempview.findViewById(R.id.count_product);
                Integer pos   = (Integer) viewHolder.decrease.getTag(R.integer.btn_minus_pos);

                int total = productItems.get(pos).getCountProduct();
                if (total>0){
                    int countProduct = Integer.parseInt(tv.getText().toString()) - 1;
                    tv.setText(String.valueOf(countProduct));
                    productItems.get(pos).setCountProduct(countProduct);
                    produk.kurang(pos);
                }
            }
        });
    } else {
        viewHolder.checkBox.setChecked(false);

        //fungsi untuk reset jumlah harga dan produk pada checkbox
        String count = viewHolder.count.getText().toString();
        int jumlah = Integer.parseInt(count);
        int harga  = Integer.parseInt(productItems.get(position).getProduct_price());
        int kurang = jumlah * harga;
        viewHolder.count.setText("0");
        productItems.get(position).setCountProduct(0);
        produk.kurangCheckbox(kurang);
    }

    return view;
}

public ArrayList<ProductModel> getAllData(){
    return productItems;
}

public void setCheckBox(int position){
    ProductModel items = productItems.get(position);
    items.setCheckbox(!items.isCheckbox());
    notifyDataSetChanged();
}

static class ViewHolder{
    TextView decrease, count, increase, price;
    CheckBox checkBox;
}

```

}