title: Attempt to re-open an already-closed object: java.lang.IllegalStateException:?
body: <p>I know this question has asked many times in SO,but i couldn't figure out my exact problem.</p>
  
  <p>I am using the following code to get the data from the database(Table1) and update another Table2 based on retrieval value. Its working fine in some android versions but when i gone to test with Android 4.0.3. I am geting this <code>java.lang.IllegalStateException:?.attempt to re-open an already-closed object</code> at <code>sum_cursor.moveToNext();</code>.</p>
  
  <p><strong>I am using this code in AsyncTask.</strong></p>
  
  <pre><code> /** Sum of total matched values*/
              Cursor sum_cursor = db.gettotalMatchvalue(this);
               if(sum_cursor!=null)
               {
                   sum_cursor.moveToFirst();
                   for(int j=0; j&lt;sum_cursor.getCount();j++)
                   {    
                       float totalmatchedscore = sum_cursor.getInt(0);
                       float totalingredients = Float.parseFloat(sum_cursor.getString(sum_cursor.getColumnIndex(APPDatabase.CK_TOTALINCREDIENTS)));
                       /**average = totalscore/totalingredients*/
                       double average = totalmatchedscore/totalingredients;
                       int id = Integer.parseInt(sum_cursor.getString(sum_cursor.getColumnIndex(APPDatabase.CK_ID))); 
  
                   db.updateAverage(id, average); 
                   sum_cursor.moveToNext(); //Here is the problem
                   }  
               }   
               db.close();  
  </code></pre>
  
  <p>My update method coding</p>
  
  <pre><code>/** Update average */
  public void updateAverage(int id,double average)
  {
      SQLiteDatabase db = getWritableDatabase();
      ContentValues values = new ContentValues();
      values.put(CK_FINALVALUE,average);
      db.update(TABLE, values,CK_ID+" = "+id , null);   
  }
  </code></pre>
  
  <p>What i am doing wrong here?</p>
  
  <p>I know many of you come across this situation. Could you help me guys.</p>
  
  <p>Thanks for your help.</p>