Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite Cursor Window allocation 2048 kb failed

  public List<Diagnosis_tble> GetAllPatientDetails()
     {
      List<Diagnosis_tble> DiagnosistblList = new   ArrayList<Diagnosis_tble>();  
      String selectQuery = "SELECT  * FROM " + TABLE_Diagnosistble + "";  
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor cursor = null;

       {  
        cursor = db.rawQuery(selectQuery, null);

      if(cursor.getCount() > 0)
      {
        if (cursor.moveToFirst()) 

         do{     
            Diagnosis_tble  diagCreation_tble = new Diagnosis_tble(); 

             diagCreation_tble.SetDiagnosisID(cursor.getString(0));
             diagCreation_tble.SetPName(cursor.getString(1));
             diagCreation_tble.SetHospitalNo(cursor.getString(2));
             diagCreation_tble.SetPGender(cursor.getString(3));
             diagCreation_tble.SetPacemaker(cursor.getString(4));
             diagCreation_tble.SetDiagType(cursor.getString(5));
             diagCreation_tble.SetP_Age(cursor.getString(6));
             diagCreation_tble.SetDeviceID(cursor.getString(7));
             diagCreation_tble.SetDiagStrtTime(cursor.getString(8));
             diagCreation_tble.SetDiagEndTime(cursor.getString(9));
             diagCreation_tble.SetDiagStatus(cursor.getString(10));
             diagCreation_tble.SetReportStatus(cursor.getString(11));
             diagCreation_tble.SetUploadStatus(cursor.getString(12));

          DiagnosistblList.add(diagCreation_tble); 

         }while (cursor.moveToNext());

          return DiagnosistblList; 
      }else
      {
          return null;
      } 
    }
    finally
    {
        cursor.close();
    }
}  

what is wrong in this code?

I am getting this Exception:

 java.lang.RuntimeException: Unable to start activity 
 ComponentInfo{com.abc.TestApp/com.abc.TestApp.LoadData}:
 android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 
like image 384
Tejas Avatar asked Nov 12 '13 13:11

Tejas


1 Answers

I have faced the same trouble as you. What I did is I went all over my application data classes and close all other cursor objects which were not closed. so I guess same happen in your application also, open your data classes and find the cursors that didn't closed and close them

like image 164
Dehan Wjiesekara Avatar answered Oct 17 '22 00:10

Dehan Wjiesekara