• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

ConcurrentModificationException  RSS feed

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got this error java.util.ConcurrentModificationException
how to solved this problem

package com.gate;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ConcurrentModificationException;

import android.R.integer;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;

public class MainEdtShifting extends Activity {

private Button btnexit,btnback,btnSearch,BtnSave,BtnReset;
ProgressDialog pDialog;
JSONArray dataJSON = null;
ArrayList<SetterGetter> tampung ;
ArrayList<SetterGetter> tampungdetail ;
ArrayList<SetterGetter> tampungspin ;
AutoCompleteTextView txtNoContainer ;
DataAdapter adapter;
static EditText EdtTglShiftting;
private int hit;
EditText txtBlock,txtRow,txtCol,txtStack ;
EditText txtBlock1,txtRow1,txtCol1,txtStack1 ;
ListView lv;

private static final String url_update_container = "";
private static final String TAG_NoContainer = "NoContainer";
private static final String TAG_Block = "Block";
private static final String TAG_Row = "Row";
private static final String TAG_Col = "Col";
private static final String TAG_Stack = "Stack";
private static final String TAG_SUCCESS = "success";
private static final String TAG_userlogin = "userlogin" ;
private int success = 0 ;

private String userlogin;
private Spinner spinner_condition ;

   protected void onCreate(Bundle savedInstanceState) {
       Intent dapatdata = this.getIntent();
userlogin = dapatdata.getStringExtra("userlogin");

tampung = new ArrayList<SetterGetter>();
txtNoContainer = (AutoCompleteTextView) findViewById(R.id.txtNoContainer);
       new GetDataKontainer().execute();

public class GetDataKontainer extends AsyncTask<String, String, String> {
 protected void onPreExecute() {
  pDialog = new ProgressDialog(MainEdtShifting.this);
  pDialog.setMessage("Loading Data...");

 protected String doInBackground(String... arg0) {    
 String url = "" ;
 Log.e("proses : ", "---------->" + url);
 JSONParser jParser = new JSONParser();
 JSONObject json = jParser.getJSONFromUrl(url);
 System.out.println(" tampung --------------> " + tampung);
  try {
  dataJSON = json.getJSONArray("list_container");
  System.out.println(" kesini --------------> ");
  for (int i = 0; i < dataJSON.length(); i++) {
JSONObject c = dataJSON.getJSONObject(i);

tampung.add(new SetterGetter(c.getString("cont_number"), c.getString("block_loc"), c.getString("rowss"), c.getString("col"), c.getString("stack"), "",c.getString("contstatus"))) ;


  } catch (JSONException e) {
  return null;
 protected void onPostExecute(String result) {  

List<SetterGetter> list = new ArrayList<SetterGetter>();

       for(SetterGetter karyawan:tampung){
        list.add(new SetterGetter(karyawan.getcontno().toString(), karyawan.getblock().toString(), karyawan.getrow().toString(), karyawan.getcol().toString(), karyawan.getstack().toString(),"",karyawan.getcontstatus().toString())) ;
        Iterator<SetterGetter> iter = list.iterator();
        SetterGetter str = iter.next();
        String AA = karyawan.getcontno().toString(); String BB = karyawan.getblock().toString();
            String CC = karyawan.getrow().toString(); String DD = karyawan.getcol().toString();
            String EE = karyawan.getstack().toString(); String FF = karyawan.getcontstatus().toString();
            String KK = str.getcontno().toString(); String LL = str.getblock().toString();
            String MM = str.getrow().toString(); String NN = str.getcol().toString();
            String OO = str.getstack().toString(); String PP = str.getcontstatus().toString();
            if(KK.equals(AA) && LL.equals(BB) && MM.equals(CC) && NN.equals(DD) && OO.equals(EE) && PP.equals(FF)){
        list.add(new SetterGetter(karyawan.getcontno().toString(), karyawan.getblock().toString(), karyawan.getrow().toString(), karyawan.getcol().toString(), karyawan.getstack().toString(),"",karyawan.getcontstatus().toString())) ;
        }catch (ConcurrentModificationException e) {
       txtNoContainer = (AutoCompleteTextView) findViewById(R.id.txtNoContainer);
       adapter = new DataAdapter(MainEdtShifting.this, R.layout.frmeditshifting, R.id.txtnocont, list);
       txtNoContainer.setText("") ;


[Thumbnail for ConcurrentModificationException.jpg]
Saloon Keeper
Posts: 5389
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem occurs in line 121 of the DataAdapter class, so we'd need to see the relevant part of that.

The relevant variable is probably the (not-too-well-named) "list", so you should start by examining where (and when) that is modified.
Something must be done about this. Let's start by reading this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!