5
  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();
    }
}  

このコードで何が間違っていますか?

私はこの例外を取得しています:

 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. 
4

1 に答える 1

7

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

于 2013-12-11T05:05:23.050 に答える